public CommandRunner() { var path = AppDomain.CurrentDomain.BaseDirectory; var fileSystem = new FileSystem(); bool isFound = fileSystem.FileExists(path, @"src\fubu\bin\debug", "fubu.exe"); while (!isFound) { path = Path.Combine(path, ".."); isFound = fileSystem.FileExists(path, @"src\fubu\bin\debug", "fubu.exe"); } _solutionDirectory = Path.GetFullPath(path); }
public void create_test_zip_to_a_nonexistent_path() { var fileSystem = new FileSystem(); fileSystem.DeleteDirectory(".\\nonexist"); fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeFalse(); fileSystem.WriteStringToFile(".\\bob.txt","hi"); var service = new ZipFileService(fileSystem); service.CreateZipFile(".\\nonexist\\silly.zip", f=> { f.AddFile(".\\bob.txt",""); }); fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeTrue(); }
public static Project LoadForFolder(string folder) { var system = new FileSystem(); var file = folder.AppendPath(FILE); var project = system.FileExists(file) ? system.LoadFromFile<Project>(file) : new Project(); project.ProjectPath = folder; return project; }
private void readDirectivesFromFile(FileSystem fileSystem) { Console.WriteLine("Reading directives from " + _file); if (!fileSystem.FileExists(_file)) { throw new CommandFailureException("Designated serenity/jasmine file at {0} does not exist".ToFormat(_file)); } fileSystem.ReadTextFile(_file, ReadText); }
public static string LocationOfRunner(string file) { var folder = RippleExeLocation().ParentDirectory(); var system = new FileSystem(); if (system.FileExists(folder.AppendPath(file))) { return folder.AppendPath(file).ToFullPath(); } return CodeDirectory().AppendPath("ripple", file); }
public void ReadFile() { Console.WriteLine("Reading directives from " + _file); var fileSystem = new FileSystem(); if (!fileSystem.FileExists(_file)) { throw new CommandFailureException("Designated serenity/jasmine file at {0} does not exist".ToFormat(_file)); } fileSystem.ReadTextFile(_file, ReadText); }
public void MoveTo(string destDirName) { if (destDirName == null) { throw new ArgumentNullException(nameof(destDirName)); } if (destDirName.Length == 0) { throw new ArgumentException(SR.Argument_EmptyFileName, nameof(destDirName)); } string destination = Path.GetFullPath(destDirName); string destinationWithSeparator = PathInternal.EnsureTrailingSeparator(destination); string sourceWithSeparator = PathInternal.EnsureTrailingSeparator(FullPath); if (string.Equals(sourceWithSeparator, destinationWithSeparator, PathInternal.StringComparison)) { throw new IOException(SR.IO_SourceDestMustBeDifferent); } string sourceRoot = Path.GetPathRoot(sourceWithSeparator); string destinationRoot = Path.GetPathRoot(destinationWithSeparator); if (!string.Equals(sourceRoot, destinationRoot, PathInternal.StringComparison)) { throw new IOException(SR.IO_SourceDestMustHaveSameRoot); } // Windows will throw if the source file/directory doesn't exist, we preemptively check // to make sure our cross platform behavior matches NetFX behavior. if (!Exists && !FileSystem.FileExists(FullPath)) { throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, FullPath)); } if (FileSystem.DirectoryExists(destination)) { throw new IOException(SR.Format(SR.IO_AlreadyExists_Name, destinationWithSeparator)); } FileSystem.MoveDirectory(FullPath, destination); Init(originalPath: destDirName, fullPath: destinationWithSeparator, fileName: null, isNormalized: true); // Flush any cached information about the directory. Invalidate(); }
public static void Move(string sourceFileName, string destFileName, bool overwrite) { ArgumentException.ThrowIfNullOrEmpty(sourceFileName); ArgumentException.ThrowIfNullOrEmpty(destFileName); string fullSourceFileName = Path.GetFullPath(sourceFileName); string fullDestFileName = Path.GetFullPath(destFileName); if (!FileSystem.FileExists(fullSourceFileName)) { throw new FileNotFoundException(SR.Format(SR.IO_FileNotFound_FileName, fullSourceFileName), fullSourceFileName); } FileSystem.MoveFile(fullSourceFileName, fullDestFileName, overwrite); }
private static bool DoesItemExist(ReadOnlySpan <char> path, bool isFile) { if (path.IsEmpty || path.Length == 0) { return(false); } if (!isFile) { return(FileSystem.DirectoryExists(path)); } return(PathInternal.IsDirectorySeparator(path[path.Length - 1]) ? false : FileSystem.FileExists(path)); }
public void WriteFiles() { var fileSystem = new FileSystem(); var directory = NamespacedDirectory(); writeSparkFile(directory, fileSystem); var classFile = directory.AppendPath(TopicName + ".cs"); if (!fileSystem.FileExists(classFile)) { Console.WriteLine("Writing " + classFile); var content = TopicClassTemplate.ToFormat(typeof (Topic).Namespace, FullNamespace, TopicName, Title); fileSystem.WriteStringToFile(classFile, content); } }
private void writeSparkFile(string directory, FileSystem fileSystem) { var sparkFile = directory.AppendPath(TopicName + ".spark"); if (!fileSystem.FileExists(sparkFile)) { Console.WriteLine("Writing " + sparkFile); var content = SparkTemplate.ToFormat(FullTopicClassName, Environment.NewLine); fileSystem.WriteStringToFile(sparkFile, content); } }
private string findFubuFilename() { var fileSystem = new FileSystem(); var fileName = Path.Combine(_solutionDirectory, @"src\fubu\bin\debug\fubu.exe"); if (fileSystem.FileExists(fileName)) { return fileName; } fileName = Path.Combine(_solutionDirectory, @"src\fubu\bin\release\fubu.exe"); if (fileSystem.FileExists(fileName)) { return fileName; } return _solutionDirectory.AppendPath("fubu.cmd"); }
public static Project LoadForFolder(string folder) { var system = new FileSystem(); var file = folder.AppendPath(FILE); if (system.FileExists(file)) { return system.LoadFromFile<Project>(file); } return new Project(); }
internal static bool InternalExists(string path) { return(FileSystem.FileExists(path)); }
private static string findSolutionDir(string path, bool shouldThrow = true) { if (_stopAt(path)) return null; var files = new FileSystem(); if (files.FileExists(path, SolutionFiles.ConfigFile)) { return path; } var parent = new DirectoryInfo(path).Parent; if (parent == null) { if (shouldThrow) { const string msg = "Not a ripple repository (or any of the parent directories)"; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(msg); Console.ResetColor(); throw new RippleFatalError(msg); } return null; } return findSolutionDir(parent.FullName, shouldThrow); }
public void FileSystem_FileExists_Finds_File() { IFileSystem fileSystem = new FileSystem(); var result = fileSystem.FileExists(FS.FileExists.TargetPath); Assert.IsTrue(result); }
public void can_write_ddl_by_type_with_schema_creation() { using (var store = DocumentStore.For(_ => { _.DatabaseSchemaName = "yet_another"; _.RegisterDocumentType<Company>(); _.Schema.For<User>().DatabaseSchemaName("other"); _.Events.DatabaseSchemaName = "event_store"; _.Events.EventMappingFor<MembersJoined>(); _.Connection(ConnectionSource.ConnectionString); })) { store.Schema.WriteDDLByType("allsql"); } const string filename = @"allsql\database_schemas.sql"; var fileSystem = new FileSystem(); fileSystem.FileExists(filename).ShouldBeTrue(); var contents = fileSystem.ReadStringFromFile(filename); contents.ShouldContain("CREATE SCHEMA event_store"); contents.ShouldContain("CREATE SCHEMA other"); contents.ShouldContain("CREATE SCHEMA yet_another"); }
private static string findSolutionDir(string path, bool shouldThrow = true) { if (_stopAt(path)) return null; var files = new FileSystem(); if (files.FileExists(path, SolutionFiles.ConfigFile)) { return path; } var parent = new DirectoryInfo(path).Parent; if (parent == null) { if (shouldThrow) RippleAssert.Fail("Not a ripple repository (or any of the parent directories)"); return null; } return findSolutionDir(parent.FullName); }