OAProjectItems.cs

Diff from previous changeset

The AddFromDirectory method was previously unimplemented. See the New Project from Existing Code article for a discussion on why it was added in this changeset.

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
        /// <summary>
        /// Creates a new project item from an existing directory and all files and subdirectories
        /// contained within it.
        /// </summary>
        /// <param name="directory">The full path of the directory to add.</param>
        /// <returns>A ProjectItem object.</returns>
         public override ProjectItem AddFromDirectory(string directory) {
            CheckProjectIsValid();
 
            ProjectItem result = AddFolder(directory, null);
 
            foreach (string subdirectory in Directory.EnumerateDirectories(directory)) {
                // Assuming this should only import packages
                if (File.Exists(Path.Combine(directory, subdirectory, "__init__.py"))) {
                    result.ProjectItems.AddFromDirectory(Path.Combine(directory, subdirectory));
                }
            }
 
            foreach (string filename in Directory.EnumerateFiles(directory, "*" + PythonConstants.FileExtension)) {
                result.ProjectItems.AddFromFile(Path.Combine(directory, filename));
            }
            foreach (string filename in Directory.EnumerateFiles(directory, "*" + PythonConstants.WindowsFileExtension))
            {
                result.ProjectItems.AddFromFile(Path.Combine(directory, filename));
            }
            return result;
         }

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? Click the Pineapple...