public bool DirectoryExists(DirectoryName folder) { if (folder == null) return false; foldersCheckedThatTheyExist.Add(folder); return foldersThatExist.Contains(folder); }
public PropertyService(DirectoryName configDirectory, DirectoryName dataDirectory, string propertiesName) : base(LoadPropertiesFromStream(configDirectory.CombineFile(propertiesName + ".xml"))) { this.dataDirectory = dataDirectory; this.configDirectory = configDirectory; propertiesFileName = configDirectory.CombineFile(propertiesName + ".xml"); }
public PropertyService() : base(LoadPropertiesFromStream(GetConfigDirectory().CombineFile(PropertiesName + ".xml"))) { this.configDirectory = GetConfigDirectory(); this.dataDirectory = new DirectoryName(Environment.CurrentDirectory); propertiesFileName = configDirectory.CombineFile(PropertiesName + ".xml"); }
public IEnumerable<FileName> GetFiles(DirectoryName folder, string extension, DirectorySearchOptions searchOptions = DirectorySearchOptions.None) { searchedFolders.Add(folder); searchedForFileExtensions.Add(extension); return directoryFiles[folder]; }
public DefaultAssemblySearcher(FileName mainAssemblyFileName) { if (mainAssemblyFileName == null) throw new ArgumentNullException("mainAssemblyFileName"); this.mainAssemblyFileName = mainAssemblyFileName; this.baseDirectory = mainAssemblyFileName.GetParentDirectory(); }
public void CreateDirectory(DirectoryName path) { try { Directory.CreateDirectory(path); } catch (UnauthorizedAccessException ex) { throw new IOException(ex.Message, ex); } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { return(DirectoryName.Create((string)value)); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Converts the specified absolute path into a relative path (relative to <c>this</c>). /// </summary> public DirectoryName GetRelativePath(DirectoryName path) { if (path == null) { return(null); } return(DirectoryName.Create(FileUtility.GetRelativePath(normalizedPath, path))); }
/// <summary> /// Combines this directory name with a relative path. /// </summary> public DirectoryName CombineDirectory(string relativeDirectoryName) { if (relativeDirectoryName == null) { return(null); } return(DirectoryName.Create(Path.Combine(normalizedPath, relativeDirectoryName))); }
/// <summary> /// Combines this directory name with a relative path. /// </summary> public DirectoryName Combine(DirectoryName relativePath) { if (relativePath == null) { return(null); } return(DirectoryName.Create(Path.Combine(normalizedPath, relativePath))); }
public ReadOnlyChrootFileSystem(IReadOnlyFileSystem fileSystem, DirectoryName basePath) { if (fileSystem == null) throw new ArgumentNullException("fileSystem"); if (basePath == null) throw new ArgumentNullException("basePath"); this.fileSystem = fileSystem; this.basePath = basePath; }
public RegisteredXmlSchemas(string[] readOnlySchemaFolders, string userDefinedSchemaFolder, IFileSystem fileSystem, IXmlSchemaCompletionDataFactory factory) { this.readOnlySchemaFolders.AddRange(readOnlySchemaFolders.Select(DirectoryName.Create)); this.userDefinedSchemaFolder = DirectoryName.Create(userDefinedSchemaFolder); this.fileSystem = fileSystem; this.factory = factory; }
public IEnumerable<FileName> GetFiles(DirectoryName directory, string searchPattern, DirectorySearchOptions searchOptions) { try { bool searchSubdirectories = (searchOptions & DirectorySearchOptions.IncludeSubdirectories) != 0; bool ignoreHidden = (searchOptions & DirectorySearchOptions.IncludeHidden) == 0; return FileUtility.LazySearchDirectory(directory, searchPattern, searchSubdirectories, ignoreHidden); } catch (UnauthorizedAccessException ex) { throw new IOException(ex.Message, ex); } }
public bool Equals(DirectoryName other) { if (other != null) { return(string.Equals(normalizedPath, other.normalizedPath, StringComparison.OrdinalIgnoreCase)); } else { return(false); } }
public IEnumerable<FileName> GetFiles(DirectoryName directory, string searchPattern, DirectorySearchOptions searchOptions) { return fileNames.Value.Where(delegate(FileName fn) { if (!FileUtility.MatchesPattern(fn.GetFileName(), searchPattern)) return false; if ((searchOptions & DirectorySearchOptions.IncludeSubdirectories) != 0) return FileUtility.IsBaseDirectory(directory, fn); else return directory.Equals(fn.GetParentDirectory()); }); }
/// <summary> /// Gets the directory name. /// </summary> /// <remarks> /// Corresponds to <c>System.IO.Path.GetDirectoryName</c> /// </remarks> public DirectoryName GetParentDirectory() { if (normalizedPath.Length < 2 || normalizedPath[1] != ':') { return(DirectoryName.Create(Path.Combine(normalizedPath, ".."))); } else { return(DirectoryName.Create(Path.GetDirectoryName(normalizedPath))); } }
public FileTemplateResult ShowNewFileDialog(IProject project, DirectoryName directory, IEnumerable<TemplateCategory> templates) { #if DEBUG SD.Templates.UpdateTemplates(); #endif using (NewFileDialog nfd = new NewFileDialog(project, directory, templates ?? SD.Templates.TemplateCategories)) { if (nfd.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) return nfd.result; else return null; } }
protected virtual IProject CreateProject(DirectoryName targetProjectDirectory, IProject sourceProject) { ProjectBindingDescriptor descriptor = ProjectBindingService.GetCodonPerLanguageName(TargetLanguageName); if (descriptor == null || descriptor.Binding == null) throw new InvalidOperationException("Cannot get Language Binding for " + TargetLanguageName); string projectName = sourceProject.Name + ".Converted"; FileName fileName = FileName.Create(Path.Combine(targetProjectDirectory, projectName + descriptor.ProjectFileExtension)); ProjectCreateInformation info = new ProjectCreateInformation(sourceProject.ParentSolution, fileName); info.RootNamespace = sourceProject.RootNamespace; return descriptor.Binding.CreateProject(info); }
public NewFileDialog(IProject project, DirectoryName basePath, IEnumerable<TemplateCategory> templateCategories) { this.project = project; this.basePath = basePath; this.allowUntitledFiles = basePath == null; try { InitializeComponents(); InitializeTemplates(templateCategories); InitializeView(); if (allowUntitledFiles) categoryTreeView.Select(); else ControlDictionary["fileNameTextBox"].Select(); } catch (Exception e) { MessageService.ShowException(e); } }
public SolutionWriter(TextWriter writer, DirectoryName basePath = null) { this.writer = writer; this.basePath = basePath; }
public IEnumerable<FileName> GetFiles(DirectoryName directory, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly) { try{ return Directory.EnumerateFiles(directory, searchPattern, searchOption).Select(FileName.Create); } catch(UnauthorizedAccessException e){ throw new IOException(e.Message, e); } }
public bool DirectoryExists(DirectoryName path) { return Directory.Exists(path); }
/// <summary> /// Converts the specified absolute path into a relative path (relative to <c>this</c>). /// </summary> public DirectoryName GetRelativePath(DirectoryName path) { if (path == null) return null; return DirectoryName.Create(FileUtility.GetRelativePath(normalizedPath, path)); }
/// <summary> /// Combines this directory name with a relative path. /// </summary> public DirectoryName Combine(DirectoryName relativePath) { if (relativePath == null) return null; return DirectoryName.Create(Path.Combine(normalizedPath, relativePath)); }
public static DirectoryName Create(DirectoryName directoryName) { return directoryName; }
public DirectoryName(DirectoryName path) : base(path) { }
public bool Equals(DirectoryName other) { if (other != null) return string.Equals(normalizedPath, other.normalizedPath, StringComparison.OrdinalIgnoreCase); else return false; }
public IEnumerable<FileName> GetFiles(DirectoryName directory, string searchPattern, DirectorySearchOptions searchOptions) { return fileSystem.GetFiles(basePath.Combine(directory), searchPattern, searchOptions) .Select(file => basePath.GetRelativePath(file)); }
public bool DirectoryExists(DirectoryName path) { return fileSystem.DirectoryExists(basePath.Combine(path)); }
public SolutionWriter(FileName fileName) { // we need to specify UTF8 because MSBuild needs the BOM this.writer = new StreamWriter(fileName, false, Encoding.UTF8); this.basePath = fileName.GetParentDirectory(); }
public static DirectoryName Create(DirectoryName directoryName) { return(directoryName); }
public override string SuggestFileName(DirectoryName basePath) { if (defaultName.IndexOf("${Number}") >= 0) { try { int curNumber = 1; while (true) { string fileName = StringParser.Parse(defaultName, new StringTagPair("Number", curNumber.ToString())); if (basePath == null) { bool found = false; foreach (string openFile in FileService.GetOpenFiles()) { if (Path.GetFileName(openFile) == fileName) { found = true; break; } } if (found == false) return fileName; } else if (!File.Exists(Path.Combine(basePath, fileName))) { return fileName; } ++curNumber; } } catch (Exception e) { MessageService.ShowException(e); } } return StringParser.Parse(defaultName); }
bool IReadOnlyFileSystem.DirectoryExists(DirectoryName path) { return false; }
void IFileSystem.CreateDirectory(DirectoryName path) { throw new NotSupportedException(); }
/// <summary> /// Proposes a name for the new file. /// </summary> /// <param name="basePath">The target directory where the new file will be placed. /// <c>null</c> if an untitled file will be created.</param> public abstract string SuggestFileName(DirectoryName basePath);
IEnumerable<FileName> IReadOnlyFileSystem.GetFiles(DirectoryName directory, string searchPattern, DirectorySearchOptions searchOptions) { return Enumerable.Empty<FileName>(); }
string GetResourceDirectory() { string resourceDirectory = ConfigurationSettings.AppSettings.Get("ResourceDirectory"); if (resourceDirectory != null) { var path = new DirectoryName(Path.Combine(Application.StartupPath, resourceDirectory)); return path; } return Path.Combine(Application.StartupPath, "resources"); }