FileExists() public abstract method

public abstract FileExists ( string fullPath ) : bool
fullPath string
return bool
コード例 #1
0
ファイル: CommandRunner.cs プロジェクト: hartez/fubumvc
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: Project.cs プロジェクト: storyteller/Storyteller
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: RippleFileSystem.cs プロジェクト: spascoe/ripple
        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);
        }
コード例 #6
0
ファイル: ConfigFileLoader.cs プロジェクト: jemacom/fubumvc
        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);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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);
        }
コード例 #9
0
            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));
            }
コード例 #10
0
ファイル: TopicRequest.cs プロジェクト: ventaur/FubuWorld
        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);
            }
        }
コード例 #11
0
ファイル: TopicRequest.cs プロジェクト: ventaur/FubuWorld
        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);
            }
        }
コード例 #12
0
ファイル: CommandRunner.cs プロジェクト: plurby/fubumvc
        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");
        }
コード例 #13
0
ファイル: Project.cs プロジェクト: jamesmanning/Storyteller
        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();
        }
コード例 #14
0
 internal static bool InternalExists(string path)
 {
     return(FileSystem.FileExists(path));
 }
コード例 #15
0
ファイル: RippleFileSystem.cs プロジェクト: 4lexm/ripple
        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);
        }
コード例 #16
0
 public void FileSystem_FileExists_Finds_File()
 {
     IFileSystem fileSystem = new FileSystem();
     var result = fileSystem.FileExists(FS.FileExists.TargetPath);
     Assert.IsTrue(result);
 }
コード例 #17
0
        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");
        }
コード例 #18
0
ファイル: RippleFileSystem.cs プロジェクト: bobpace/ripple
        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);
        }