public ZipFileDirectory(PathName pathName) { Name = DirectoryName.GetDirectoryName(pathName); _parse = Parse; _parse(); }
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 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 Result Open(ref DirectoryName name) { if (!name.IsValid()) { return(ResultBcat.InvalidArgument.Log()); } lock (Locker) { if (IsDirectoryOpen) { return(ResultBcat.AlreadyOpen.Log()); } var metaReader = new DeliveryCacheFileMetaAccessor(Server); Result rc = metaReader.ReadApplicationFileMeta(ApplicationId, ref name, false); if (rc.IsFailure()) { return(rc); } Count = metaReader.Count; _name = name; IsDirectoryOpen = true; return(Result.Success); } }
public DotNetNugDirectory(DirectoryName directoryName) : base(directoryName) { var manifestFile = GetChildFile("MANIFEST.json"); var manifestContent = manifestFile.ReadToEnd(); _manifest = JsonUtil.Get<Manifest>(manifestContent); }
/// <summary> /// if the folder does not exist, create a new one without or without hidden it /// </summary> public void CreateDirectory() { if (!DirectoryName.Exists) { DirectoryName.Create(); } }
private void AddDirectory(DirectoryName directory) { FileSystemWatcher watcher; lock (_watchersLock) { if (_thread == null) { _thread = new Thread(ThreadLoop) { IsBackground = true }; _thread.Start(); } if (_watchers.TryGetValue(directory, out watcher)) { return; } watcher = new FileSystemWatcher(); _watchers.Add(directory, watcher); } Logger.Log("Starting monitoring directory \"{0}\" for change notifications.", directory.FullPathName); watcher.Path = directory.FullPathName.FullName; watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.FileName; watcher.IncludeSubdirectories = true; watcher.InternalBufferSize = 50 * 1024; // 50KB sounds more reasonable than 8KB watcher.Changed += WatcherOnChanged; watcher.Created += WatcherOnCreated; watcher.Deleted += WatcherOnDeleted; watcher.Renamed += WatcherOnRenamed; watcher.Error += WatcherOnError; watcher.EnableRaisingEvents = true; }
public ReplicationFolder(Ship parentShip, string directoryFullPath, string relocationFolderName) { this.ParentShip = parentShip; FullPath = directoryFullPath; DirectoryName = Path.GetFileName(FullPath); RelocationFolder = relocationFolderName; RelocationFullPath = Path.GetDirectoryName(directoryFullPath) + "\\" + relocationFolderName + "\\" + DirectoryName + "\\"; if (!Directory.Exists(RelocationFullPath)) { Directory.CreateDirectory(RelocationFullPath); } if (directoryFullPath.Length == 26) { ReplicationMode = DirectoryName.Substring(0, 5); ReplicationYYMM = DirectoryName.Substring(5, 4); ReplicationId = Convert.ToInt32(DirectoryName.Substring(9, 3)); ReplicationReference = ReplicationMode + ReplicationYYMM + ReplicationId.ToString("D3"); ReplicationAckIMO = Convert.ToInt32(DirectoryName.Substring(12, 7)); ReplicationYYMMDD = DirectoryName.Substring(19, 6); } IsDefaultLocationForDeletion = false; IsRelocated = false; IsForShipReplication = false; SharePointListName = string.Empty; IsForAcknowledgement = false; ErrorMessage = string.Empty; }
/// <summary> /// Refreshes the list of files and directories at the specified path /// </summary> /// <param name="path">Path</param> public void SetPath(string path) { if (!Directory.Exists(path)) { return; } try { DirectoryInfo di = new DirectoryInfo(path); Files.Clear(); Files.AddRange(di.GetDirectories()); Files.AddRange(di.GetFiles()); Path = path; DirectoryName.SetText(Path, false); View.Path = Path; View.SetFiles(Files); } catch (UnauthorizedAccessException ex) { throw new InvalidOperationException("Set path error", ex) { Data = { { "path", path } } }; } }
private static string GetEventFileName(DirectoryName directoryName) { string fullDir = GetDirectory(directoryName); DateTime dtNow = DateTimeEx.Now; var sb = new StringBuilder(); sb.Append(fullDir); sb.Append("\\"); sb.Append(Environment.MachineName); sb.Append("_"); sb.Append(directoryName); sb.Append("_"); if (UseMonthlyRotatingSystem) { if (dtNow.Day < 10) { sb.Append("0"); } sb.Append(dtNow.Day.ToString(CultureInfo.InvariantCulture)); } else { sb.Append(DateTimeEx.NowToDayFileString); } sb.Append(".txt"); return(sb.ToString()); }
/// <summary> /// Enumerate directories and files under the project path of |projet|. /// </summary> private IEnumerable <TraversedDirectoryEntry> TraverseFileSystem(DirectoryName startDirectoryName, bool isSymLink) { var stack = new Stack <DirectoryData>(); stack.Push(new DirectoryData(startDirectoryName, isSymLink)); while (stack.Count > 0) { _cancellationToken.ThrowIfCancellationRequested(); // cancellation var head = stack.Pop(); if (head.DirectoryName.IsAbsoluteName || _project.DirectoryFilter.Include(head.DirectoryName.RelativePath)) { var childEntries = _fileSystem.GetDirectoryEntries(_project.RootPath.Combine(head.DirectoryName.RelativePath)); var childFileNames = new List <FileName>(); // Note: Use "for" loop to avoid memory allocations. for (var i = 0; i < childEntries.Count; i++) { DirectoryEntry entry = childEntries[i]; if (entry.IsDirectory) { stack.Push(new DirectoryData(_fileSystemNameFactory.CreateDirectoryName(head.DirectoryName, entry.Name), entry.IsSymLink)); } else if (entry.IsFile) { childFileNames.Add(_fileSystemNameFactory.CreateFileName(head.DirectoryName, entry.Name)); } } yield return(new TraversedDirectoryEntry(head, childFileNames)); } } }
static void GitGetFiles(string wcRoot, GitStatusSet statusSet) { string git = Git.FindGit(); if (git == null) { return; } using (ProcessRunner runner = new ProcessRunner()) { runner.WorkingDirectory = DirectoryName.Create(wcRoot); runner.RedirectStandardOutput = true; runner.RedirectStandardError = true; runner.Start(git, "ls-files"); // process stderr in background var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category); // process stderr on current thread: using (var reader = runner.OpenStandardOutputReader()) { string line; while ((line = reader.ReadLine()) != null) { if (line.Length > 0) { statusSet.AddEntry(line, GitStatus.OK); } } } errorTask.Wait(); } }
void AddTextTemplatesToFolder(string path, params string[] fileNames) { DirectoryName templateFolder = DirectoryName.Create(path); var templateFileNames = fileNames.Select(FileName.Create).ToArray(); fakeFileSystem.Stub(f => f.GetFiles(templateFolder, "*.tt")).Return(templateFileNames); }
private static string MaintainDirectory(DirectoryName directoryName) { string dir = GetDirectory(directoryName); FileSystem.TryCreateDirectory(dir); return(dir); }
bool ILogger.WriteCore(LogType logType, string content, Exception exception, Func <string, Exception, string> formatter) { try { if (_isDispose) { return(false); //throw new Exception("日志服务已经释放"); } content = string.Format("{0}-{1}", this.Id, content); string msg = formatter(content, exception); string directoryName = String.Format("{0}\\{1}\\{2}\\", DirectoryName.TrimEnd('\\'), DateTime.Now.ToString(this.Configuration.DirectoryDatePattern), logType.GetValue()); if (logType == LogType.Error) { Log(directoryName, FileName, msg, EmergencyWriteLogDirectory); EmergencyWriteAutoResetEvent.Set(); } else { Log(directoryName, FileName, msg, WriteLogDirectory); WriteAutoResetEvent.Set(); } return(true); } catch (Exception ex) { ILogger logger = FileLoggerFactory.Default.Create("LogError.log"); logger.WriteError("日志写入出错:", ex); return(false); } }
public void AddDirectoryFiles(string folder, string[] files) { foreach (var file in files) { directoryFiles.Add(DirectoryName.Create(folder), FileName.Create(file)); } }
public void CopyTo(DirectoryName path) { //refactor this out? if (!System.IO.Directory.Exists(path.GetPath())) { System.IO.Directory.CreateDirectory(path.GetPath()); } // Copy all files. var files = GetFiles(); foreach (var file in files) { var fileDestination = FileName.GetFileName(path, file.Name.GetName()); file.CopyTo(fileDestination); } // Process subdirectories. var dirs = GetDirectories(); foreach (var dir in dirs) { var destinationDir = DirectoryName.GetDirectoryName(path, dir.Name.GetName()); dir.CopyTo(destinationDir); } }
static FileName GetActiveXInteropFileName(DirectoryName outputFolder, string include) { if (include.StartsWith("ax", StringComparison.OrdinalIgnoreCase)) { return(outputFolder.CombineFile(String.Concat("AxInterop.", include.Substring(2), ".dll"))); } return(null); }
public void CreateDirectory(DirectoryName path) { try { Directory.CreateDirectory(path); } catch (UnauthorizedAccessException ex) { throw new IOException(ex.Message, ex); } }
public FileName(DirectoryName parent, RelativePath relativePath) { if (parent == null) throw new ArgumentNullException("parent"); if (relativePath.IsEmpty) throw new ArgumentException("Relative path is empty", "relativePath"); _parent = parent; _relativePath = relativePath; }
public void TestGetParentDirectory() { Assert.AreEqual(@"c:\", FileName.Create("c:\\file.txt").GetParentDirectory().ToString()); Assert.IsNull(DirectoryName.Create("c:\\").GetParentDirectory()); Assert.AreEqual("relpath", FileName.Create("relpath\\file.txt").GetParentDirectory().ToString()); Assert.AreEqual(".", FileName.Create("file.txt").GetParentDirectory().ToString()); Assert.AreEqual("..", FileName.Create("..\\file.txt").GetParentDirectory().ToString()); }
public void FoldersRecordedWhenDirectoryExistsMethodCalled() { string[] expectedFolders = new string[] { @"c:\temp", @"c:\projects" }; fileSystem.DirectoryExists(DirectoryName.Create(@"c:\temp")); fileSystem.DirectoryExists(DirectoryName.Create(@"c:\projects")); Assert.AreEqual(expectedFolders, fileSystem.FoldersCheckedThatTheyExist); }
public override DirectoryName Combine(DirectoryName child) { var pathName = Name.Combine(child.Name) as AbsolutePathName; if (pathName == null) throw new InvalidOperationException("Unable to combine " + Name + " with " + child); return new AbsoluteDirectoryName(pathName); }
// Open(nn::bcat::DirectoryName) public ResultCode Open(ServiceCtx context) { DirectoryName directoryName = context.RequestData.ReadStruct <DirectoryName>(); Result result = _base.Get.Open(ref directoryName); return((ResultCode)result.Value); }
public void SearchPatternsRecordedWhenCallingGetFilesMethod() { string[] expectedSearchPatterns = new string[] { "*.*", @"*.xml" }; fileSystem.GetFiles(DirectoryName.Create(@"c:\temp"), "*.*"); fileSystem.GetFiles(DirectoryName.Create(@"c:\projects"), "*.xml"); Assert.AreEqual(expectedSearchPatterns, fileSystem.SearchedForFileExtensions); }
public void SearchedFoldersRecordedWhenCallingGetFilesMethod() { string[] expectedSearchedFolders = new string[] { @"c:\temp", @"c:\projects" }; fileSystem.GetFiles(DirectoryName.Create(@"c:\temp"), String.Empty); fileSystem.GetFiles(DirectoryName.Create(@"c:\projects"), String.Empty); Assert.AreEqual(expectedSearchedFolders, fileSystem.SearchedFolders); }
public static void EnableLogging(DirectoryName directoryName, bool enable) { if (enableLogging.Count == 0) { InitEnableLogging(); } enableLogging[directoryName] = enable; }
public void GivenADirectoryWithAFile() { _fs = new DotNetFileSystem(); _dir = new DotNetDirectory(DirectoryName.GetDirectoryName("bob")); var file = _dir.GetChildFile("test.txt"); _fs.CreateDirectory(_dir); _fs.CreateFile(file); }
public DefaultAssemblySearcher(FileName mainAssemblyFileName) { if (mainAssemblyFileName == null) { throw new ArgumentNullException("mainAssemblyFileName"); } this.mainAssemblyFileName = mainAssemblyFileName; this.baseDirectory = mainAssemblyFileName.GetParentDirectory(); }
public RelativeDirectoryName(DirectoryName parent, RelativePathName relativePathName) { if (parent == null) throw new ArgumentNullException("parent"); if (relativePathName.IsEmpty) throw new ArgumentException("Relative path is empty", "relativePathName"); _parent = parent; _relativePathName = relativePathName; }
public Result ReadApplicationFileMeta(ulong applicationId, ref DirectoryName directoryName, bool allowMissingMetaFile) { Span <byte> metaPath = stackalloc byte[0x50]; Server.GetStorageManager().GetFilesMetaPath(metaPath, applicationId, ref directoryName); return(Read(new U8Span(metaPath), allowMissingMetaFile)); }
public OpcFileDirectory(PathName pathName) { _directories = new Dictionary <string, OpcDirectory>(); _files = new Dictionary <string, OpcFile>(); Name = DirectoryName.GetDirectoryName(pathName); Parse(); }
public bool DirectoryExists(DirectoryName folder) { if (folder == null) { return(false); } foldersCheckedThatTheyExist.Add(folder); return(foldersThatExist.Contains(folder)); }
public FileName CreateFileName(DirectoryName parent, string name) { var directory = FindDirectory(parent); if (directory != null) { // Note: We found the corresponding parent, we just need to check the "simple" name part of the relative name. int index = SortedArrayHelpers.BinarySearch(directory.ChildFiles, name, FileComparer); if (index >= 0) { return directory.ChildFiles[index]; } } return _previous.CreateFileName(parent, name); }
public DirectoryName CreateDirectoryName(DirectoryName parent, string simpleName) { var directory = FindDirectory(parent); if (directory != null) { // Note: We found the corresponding parent, we just need to check the "simple" name part of the relative name. int index = SortedArray.BinarySearch(directory.DirectoryEntries, simpleName, DirectoryComparer); if (index >= 0) { return directory.DirectoryEntries[index].DirectoryName; } } return _previous.CreateDirectoryName(parent, simpleName); }
private DirectorySnapshot FindDirectory(DirectoryName name) { if (name.IsAbsoluteName) return FindRootDirectory(name.FullPath); var parent = FindDirectory(name.Parent); if (parent == null) return null; // Note: We found the corresponding parent, we just need to check the "simple" name part of the relative name. var index = SortedArrayHelpers.BinarySearch(parent.ChildDirectories, name, DirectoryNameComparer); if (index < 0) return null; return parent.ChildDirectories[index]; }
public void CopyTo(DirectoryName path) { //refactor this out? if (!System.IO.Directory.Exists(path.GetPath())) System.IO.Directory.CreateDirectory(path.GetPath()); // Copy all files. var files = GetFiles(); foreach (var file in files) { var fileDestination = FileName.GetFileName(path, file.Name.GetName()); file.CopyTo(fileDestination); } // Process subdirectories. var dirs = GetDirectories(); foreach (var dir in dirs) { var destinationDir = DirectoryName.GetDirectoryName(path, dir.Name.GetName()); dir.CopyTo(destinationDir); } }
private void RemoveDirectory(DirectoryName directory) { FileSystemWatcher watcher; lock (_watchersLock) { if (!_watchers.TryGetValue(directory, out watcher)) return; _watchers.Remove(directory); } Logger.Log("Removing directory \"{0}\" from change notification monitoring.", directory.FullPathName); watcher.Dispose(); }
public DirectoryName CreateDirectoryName(DirectoryName parent, string directoryName) { var relativePath = parent.RelativePathName.CreateChild(directoryName); return new RelativeDirectoryName(parent, relativePath); }
public FileName CreateFileName(DirectoryName parent, string simpleName) { var relativePath = parent.RelativePathName.CreateChild(simpleName); return new FileName(parent, relativePath); }
public bool Equals(DirectoryName other) { return other != null && string.Equals(NormalizedPath, other.NormalizedPath, StringComparison.OrdinalIgnoreCase); }
public void CopyTo(DirectoryName path) { throw new NotImplementedException(); }
private void AddDirectory(DirectoryName directory) { FileSystemWatcher watcher; lock (_watchersLock) { if (_thread == null) { _thread = new Thread(ThreadLoop) {IsBackground = true}; _thread.Start(); } if (_watchers.TryGetValue(directory, out watcher)) return; watcher = new FileSystemWatcher(); _watchers.Add(directory, watcher); } Logger.Log("Starting monitoring directory \"{0}\" for change notifications.", directory.FullPathName); watcher.Path = directory.FullPathName.FullName; watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.FileName; watcher.IncludeSubdirectories = true; watcher.InternalBufferSize = 50 * 1024; // 50KB sounds more reasonable than 8KB watcher.Changed += WatcherOnChanged; watcher.Created += WatcherOnCreated; watcher.Deleted += WatcherOnDeleted; watcher.Renamed += WatcherOnRenamed; watcher.Error += WatcherOnError; watcher.EnableRaisingEvents = true; }
public DirectoryName(DirectoryName path) : base(path) { }
public DirectorySnapshot(DirectoryName directoryName, ReadOnlyCollection<DirectorySnapshot> directoryEntries, ReadOnlyCollection<FileName> files) { _directoryName = directoryName; _directoryEntries = directoryEntries; _files = files; }
public AssemblyDirectory(DirectoryName name, Directory parent) { Name = name; Parent = parent; _exists = true; }
public static DirectoryName Create(DirectoryName directoryName) { return directoryName; }
public AssemblyDirectory(DirectoryName name, Directory parent, bool exists) : this(name, parent) { _exists = false; }
public override DirectoryName Combine(DirectoryName child) { return InternalCombine(Name.Combine(child.Name)); }
/// <summary> /// Combines this directory name with a relative path. /// </summary> public DirectoryName Combine(DirectoryName relativePath) { return relativePath == null ? null : Create(Path.Combine(NormalizedPath, relativePath)); }
public DirectoryData(DirectoryName directoryName, bool isSymLink) { _directoryName = directoryName; _isSymLink = isSymLink; }
/// <summary> /// Converts the specified absolute path into a relative path (relative to <c>this</c>). /// </summary> public DirectoryName GetRelativePath(DirectoryName path) { return path == null ? null : Create(FileUtility.GetRelativePath(NormalizedPath, path)); }
public ZippedDirectory(DirectoryName name, Directory parent, bool exists) : this(name, parent) { _exists = false; }
public ZippedDirectory(DirectoryName name, Directory parent) { Name = name; Parent = parent; _exists = true; }
public ZippedDirectory(DirectoryName name, Directory parent) { Name = name; Parent = parent; }