Exemplo n.º 1
0
        static string FilenameFromSpan(CppSourceSpan cppSpan)
        {
            var span = cppSpan.ToString();

            span = span.Substring(0, span.IndexOf("("));
            return(Path.GetFileName(span));
        }
Exemplo n.º 2
0
        public static string FolderFromBaseSrcFolder(this CppSourceSpan cppSpan, string baseSrcFolder)
        {
            var path = cppSpan.FilePath();

            if (cppSpan.FilePath().IndexOf(baseSrcFolder) == -1)
            {
                return(Path.GetFileName(Path.GetDirectoryName(path)));
            }
            return(Path.GetDirectoryName(path.Substring(path.IndexOf(baseSrcFolder) + baseSrcFolder.Length + 1)));
        }
Exemplo n.º 3
0
        public static void CopyTo(this CppSourceSpan cppSpan, Config config)
        {
            var dst = Path.Combine(config.DstDir, "thirdparty", config.BaseSourceFolder, cppSpan.FolderFromBaseSrcFolder(config.BaseSourceFolder));

            // we could have a header outside of our BaseSourceFolder. in that case stick it in a folder in thirdparty
            if (cppSpan.FilePath().IndexOf(config.BaseSourceFolder) == -1)
            {
                dst = Path.Combine(config.DstDir, "thirdparty", cppSpan.FolderFromBaseSrcFolder(config.BaseSourceFolder));
            }
            Directory.CreateDirectory(dst);

            File.Copy(cppSpan.FilePath(), Path.Combine(dst, cppSpan.Filename()), true);
        }
Exemplo n.º 4
0
        static ParsedFile GetOrCreateFile(List <ParsedFile> files, CppSourceSpan span, bool singleFileExport)
        {
            if (singleFileExport)
            {
                if (files.Count == 0)
                {
                    files.Add(new ParsedFile(null, null));
                }
                return(files[0]);
            }

            var filename = span.FilenameNoExtension();
            var folder   = span.Folder();

            var file = files.Where(f => f.Filename == filename && f.Folder == folder).FirstOrDefault();

            if (file == null)
            {
                file = new ParsedFile(filename, folder);
                files.Add(file);
            }
            return(file);
        }
Exemplo n.º 5
0
        public static string FilePath(this CppSourceSpan cppSpan)
        {
            var span = cppSpan.ToString();

            return(span.Substring(0, span.IndexOf("(")));
        }
Exemplo n.º 6
0
 public static string Folder(this CppSourceSpan cppSpan)
 {
     return(Path.GetFileName(Path.GetDirectoryName(cppSpan.FilePath())));
 }
Exemplo n.º 7
0
 public static string FilenameNoExtension(this CppSourceSpan cppSpan)
 {
     return(cppSpan.Filename().Replace(".h", ""));
 }
Exemplo n.º 8
0
 public static string Filename(this CppSourceSpan cppSpan)
 {
     return(Path.GetFileName(cppSpan.FilePath()));
 }