Esempio n. 1
0
        void ScanForAddedFiles(XcodeSyncBackContext ctx, HashSet <string> knownFiles, string directory, string relativePath)
        {
            foreach (var file in Directory.EnumerateFiles(directory))
            {
                if (file.EndsWith("~") || file.EndsWith(".m"))
                {
                    continue;
                }

                if (knownFiles.Contains(file))
                {
                    continue;
                }

                if (file.EndsWith(".h"))
                {
                    NSObjectTypeInfo parsed = NSObjectInfoService.ParseHeader(file);

                    ctx.TypeSyncJobs.Add(XcodeSyncObjcBackJob.NewType(parsed, relativePath));
                }
                else
                {
                    FilePath original, relative;

                    if (relativePath != null)
                    {
                        relative = new FilePath(Path.Combine(relativePath, Path.GetFileName(file)));
                    }
                    else
                    {
                        relative = new FilePath(Path.GetFileName(file));
                    }

                    original = ctx.Project.BaseDirectory.Combine(relative);

                    ctx.FileSyncJobs.Add(new XcodeSyncFileBackJob(original, relative, true));
                }
            }

            foreach (var dir in Directory.EnumerateDirectories(directory))
            {
                string relative;

                // Ignore *.xcodeproj directories and any directories named DerivedData at the toplevel
                if (dir.EndsWith(".xcodeproj") || (relativePath == null && Path.GetFileName(dir) == "DerivedData"))
                {
                    continue;
                }

                if (relativePath != null)
                {
                    relative = Path.Combine(relativePath, Path.GetFileName(dir));
                }
                else
                {
                    relative = Path.GetFileName(dir);
                }

                ScanForAddedFiles(ctx, knownFiles, dir, relative);
            }
        }