Inheritance: IFileSystem
示例#1
0
        public void can_write_ddl_by_type_smoke_test_for_document_creation()
        {
            using (var store = DocumentStore.For(_ =>
            {
                _.RegisterDocumentType<User>();
                _.RegisterDocumentType<Company>();
                _.RegisterDocumentType<Issue>();

                _.Connection(ConnectionSource.ConnectionString);
            }))
            {
                store.Schema.WriteDDLByType("allsql");
            }

            var fileSystem = new FileSystem();
            var files = fileSystem.FindFiles("allsql", FileSet.Shallow("*.sql")).ToArray();

            files.Select(Path.GetFileName)
                .Where(x => x != "all.sql" && x != "database_schemas.sql").OrderBy(x => x)
                .ShouldHaveTheSameElementsAs("company.sql", "issue.sql", "mt_hilo.sql", "user.sql");

            files.Each(file =>
            {
                var contents = fileSystem.ReadStringFromFile(file);

                contents.ShouldContain("CREATE TABLE");
                contents.ShouldContain("CREATE OR REPLACE FUNCTION");
            });
        }
示例#2
0
		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var sourceCode = file.ContentAsUtf8();
			var prelude = GetPrelude(file.Directory);
			var fs = new FileSystem(file.Directory);
			return SlideParser.ParseCode(sourceCode, new SlideInfo(unitName, file, slideIndex), prelude, fs);
		}
示例#3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            lblError.Visible = false;

            byte[] fileData;
            CFile file = new FileSystem(Globals.CurrentIdentity).GetFile(Convert.ToInt32(Request.Params["FileID"]));
            string filename= file.Name;

            if (file.IsDirectory()) {
                fileData = GetDirectoryData(file);
                filename += ".zip";
            }
            else {
                try {
                    new FileSystem(Globals.CurrentIdentity).LoadFileData(file);
                } catch (CustomException er) {
                    PageError(er.Message);
                    return;
                }
                fileData = file.RawData;
            }

            Response.Clear();
            Response.ContentType = "application/octet-stream; name=" + filename;
            Response.AddHeader("Content-Disposition","attachment; filename=" + filename);
            Response.AddHeader("Content-Length", fileData.Length.ToString());
            Response.Flush();

            Response.OutputStream.Write(fileData, 0, fileData.Length);
            Response.Flush();
        }
示例#4
0
        public static IEnumerable<Assembly> FindAssemblies(Action<string> logFailure)
        {
            var assemblyPath = AppDomain.CurrentDomain.BaseDirectory;
            var binPath = FindBinPath();
            if (StringExtensions.IsNotEmpty(binPath))
            {
                assemblyPath = assemblyPath.AppendPath(binPath);
            }


            var files = new FileSystem().FindFiles(assemblyPath, FileSet.Deep("*.dll;*.exe"));
            foreach (var file in files)
            {
                var name = Path.GetFileNameWithoutExtension(file);
                Assembly assembly = null;

                try
                {
                    assembly = AppDomain.CurrentDomain.Load(name);
                }
                catch (Exception)
                {
                    logFailure(file);
                }

                if (assembly != null) yield return assembly;
            }
        }
        public virtual void Setup()
        {
            _latestRecentBackupQuery = A.Fake<LatestRecentBackupQuery>();
            _fileSystem = A.Fake<FileSystem>();

            _defaultSettings = new BackupSettings { BackupTargetDestination = "TargetDestination" };
        }
示例#6
0
 public FileSystemIntegrationTester()
 {
     _testDirectory = new TestDirectory();
     _testDirectory.ChangeDirectory();
     _fileSystem = new FileSystem();
     _basePath = Path.GetTempPath();
 }
        public void SetUp()
        {
            var system = new FileSystem();
            system.DeleteDirectory("geonosis");
            system.CreateDirectory("geonosis");

            var data1 = newData();
            var data2 = newData();
            var data3 = newData();
            var data4 = newData();
            var data5 = newData();
            var data6 = newData();
            var data7 = newData();

            saveData(data1, "a", "a1");
            saveData(data2, "a", "a2");
            saveData(data3, "b", "b3");
            saveData(data4, "b", "b4");
            saveData(data5, "c", "c5");
            saveData(data6, "c", "c6");
            saveData(data7, "c", "c7");

            var data8 = newData();
            data8["pak1"] = "pak1-value";
            PackageSettingsSource.WriteToDirectory(data8, "geonosis".AppendPath("a"));

            theCache = new PackageFilesCache();
            theCache.AddDirectory(FileSystem.Combine("geonosis", "a"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "b"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "c"));
        }
        public void should_throw_when_file_does_not_exist()
        {
            var fileSystem = new FileSystem();
            const string fileName = "does not exist";

            typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFileOrThrow<SerializeMe>(fileName));
        }
        public void VerifyCanOverride()
        {
            IFileSystem fileSystem = new FileSystem();
            var root = Path.GetPathRoot(AppDomain.CurrentDomain.BaseDirectory);
            var settings = new DeploymentSettings(root.AppendPath("dev", "test-profile"));
            IBottleRepository bottles = new BottleRepository(fileSystem, new ZipFileService(fileSystem), settings);

            var initializer = new WebAppOfflineInitializer(fileSystem);

            var deployer = new IisWebsiteCreator();

            var directive = new Website();
            directive.WebsiteName = "fubu";
            directive.WebsitePhysicalPath = root.AppendPath("dev", "test-web");
            directive.VDir = "bob";
            directive.VDirPhysicalPath = root.AppendPath("dev", "test-app");
            directive.AppPool = "fubizzle";

            directive.DirectoryBrowsing = Activation.Enable;

            initializer.Execute(directive, new HostManifest("something"), new PackageLog());

            deployer.Create(directive);

            //override test
            directive.ForceWebsite = true;
            directive.VDirPhysicalPath = root.AppendPath("dev", "test-app2");
            deployer.Create(directive);
        }
示例#10
0
文件: Program.cs 项目: emiaj/bottles
        static void Main(string[] args)
        {
            setupLog4Net();

            HostFactory.Run(h =>
            {
                h.SetDescription("Bottle Host");
                h.SetServiceName("bottle-host");
                h.SetDisplayName("display");

                h.Service<BottleHost>(c =>
                {
                    c.ConstructUsing(n =>
                    {
                        var fileSystem = new FileSystem();
                        var packageExploder = new PackageExploder(new ZipFileService(fileSystem),
                                                                  new PackageExploderLogger(ConsoleWriter.Write),
                                                                  fileSystem);
                        return new BottleHost(packageExploder, fileSystem);
                    });
                    c.WhenStarted(s => s.Start());
                    c.WhenStopped(s => s.Stop());
                });
            });
        }
示例#11
0
        public void before_all()
        {
            // setup
            _command = new NewCommand();
            _fileSystem = new FileSystem();
            _zipService = new ZipFileService(_fileSystem);
            _commandInput = new NewCommandInput();

            tmpDir = FileSystem.Combine("Templating", Guid.NewGuid().ToString());
            repoZip = FileSystem.Combine("Templating", "repo.zip");
            _zipService.ExtractTo(repoZip, tmpDir, ExplodeOptions.DeleteDestination);

            solutionFile = FileSystem.Combine("Templating", "sample", "myproject.txt");
            oldContents = _fileSystem.ReadStringFromFile(solutionFile);
            solutionDir = _fileSystem.GetDirectory(solutionFile);

            _commandInput.GitFlag = "file:///{0}".ToFormat(_fileSystem.GetFullPath(tmpDir).Replace("\\", "/"));
            _commandInput.ProjectName = "MyProject";
            _commandInput.SolutionFlag = solutionFile;
            _commandInput.OutputFlag = solutionDir;
            _commandInput.RakeFlag = "init.rb";

            _commandResult = _command.Execute(_commandInput);

            newSolutionContents = _fileSystem.ReadStringFromFile(solutionFile);
        }
示例#12
0
        /// <summary>
        /// Export data into CSV format
        /// </summary>
        public CFile Export(FileSystem fs, ExportRow.ExportRowList rows)
        {
            int i;
            MemoryStream csvstream = new MemoryStream();
            StreamWriter csvwriter = new StreamWriter(csvstream);

            //Write the data out in CSV style rows
            foreach (ExportRow row in rows) {
                for (i = 0; i < row.Fields.Count; i++) {
                    csvwriter.Write(row.Fields[i]);
                    if (i < row.Fields.Count-1)
                        csvwriter.Write(",");
                }
                csvwriter.WriteLine();
            }
            csvwriter.Flush();

            //Commit to a temp file within the FS
            //Create a temp file
            Guid guid = Guid.NewGuid();
            CFile expfile = fs.CreateFile(@"c:\system\export\" + guid.ToString(), false,
                new CFilePermission.FilePermissionList() );
            expfile.Name = expfile.ID + ".csv";
            fs.UpdateFileInfo(expfile, false);

            //Commit the data
            csvstream.Seek(0, SeekOrigin.Begin);
            expfile.RawData = Globals.ReadStream(csvstream, (int) csvstream.Length);
            fs.Edit(expfile);
            fs.Save(expfile);

            csvwriter.Close();

            return expfile;
        }
示例#13
0
        public void LoadFileBrowser()
        {
            int i=0;
            tvFiles.Nodes.Clear();
            FileSystem fs = new FileSystem(Globals.CurrentIdentity);
            foreach(string droot in m_roots) {
                CFile dirroot = fs.GetFile(droot);

                TreeNode root = new TreeNode();
                root.Text = dirroot.Alias;
                root.ImageUrl = GetFolderIcon(dirroot);
                root.NodeData = dirroot.FullPath;
                root.Expandable = ExpandableValue.Always;
                tvFiles.Nodes.Add(root);

                if (i == 0 && ViewState["gridpath"] == null) {
                    ViewState["gridpath"] = dirroot.FullPath;
                    ExpandTreeNode(root);
                }
                ++i;
            }

            BindFileGrid();
            BindClipBoard();
        }
示例#14
0
        public void TearDown()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory(theCodeDir);

            RippleFileSystem.Live();
        }
 public void before_each()
 {
     _command = new NewCommand();
     _fileSystem = new FileSystem();
     _zipService = new ZipFileService(_fileSystem);
     _commandInput = new NewCommandInput();
 }
示例#16
0
 public AssemblyInfo(CodeFile codeFile, CsProjFile projFile)
 {
     _codeFile = codeFile;
     _projFile = projFile;
     this._fileSystem = new FileSystem();
     this.Initialize();
 }
示例#17
0
        public static IEnumerable<string> FindSolutions()
        {
            var currentDirectory = Environment.CurrentDirectory.ToFullPath();
            var files = new FileSystem().FindFiles(currentDirectory, FileSet.Deep("*.sln"));

            return files.Select(x => x.ToFullPath().PathRelativeTo(currentDirectory));
        }
        public void load_from_file_or_throw_shuld_throw_when_file_does_not_exist()
        {
            var fileSystem = new FileSystem();
            const string fileName = "does not exist";

            Exception<Exception>.ShouldBeThrownBy(() => fileSystem.LoadFromFileOrThrow<SerializeMe>(fileName));
        }
示例#19
0
        public void ExportTo(string directory, Topic root, Func<Topic, string> pathing)
        {
            var fileSystem = new FileSystem();

            string sourceContent = _settings.Root.AppendPath("content");
            if (fileSystem.DirectoryExists(sourceContent))
            {
                fileSystem.CopyToDirectory(sourceContent, directory.AppendPath("content"));
            }

            root.AllTopicsInOrder().Each(topic =>
            {
                var path = pathing(topic);
                var parentDirectory = path.ParentUrl();

                if (parentDirectory.IsNotEmpty())
                {
                    fileSystem.CreateDirectory(directory.AppendPath(parentDirectory));
                }
                

                var text = _generator.Generate(topic);

                // Hoakum
                topic.Substitutions.Each((key, value) =>
                {
                    text = text.Replace(key, value);
                });

                fileSystem.WriteStringToFile(directory.AppendPath(path), text);
            });
        }
示例#20
0
文件: Program.cs 项目: jrios/bottles
        static void Main(string[] args)
        {
            File.WriteAllText("pwd.txt", System.Environment.CurrentDirectory);
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));

            HostFactory.Run(h =>
            {
                h.SetDescription("Bottle Host");
                h.SetServiceName("bottle-host");
                h.SetDisplayName("display");

                h.Service<BottleHost>(c =>
                {
                    c.ConstructUsing(n =>
                    {
                        var fileSystem = new FileSystem();
                        var packageExploder = new PackageExploder(new ZipFileService(fileSystem),
                                                                  new PackageExploderLogger(ConsoleWriter.Write),
                                                                  fileSystem);
                        return new BottleHost(packageExploder, fileSystem);
                    });
                    c.WhenStarted(s => s.Start());
                    c.WhenStopped(s => s.Stop());
                });
            });
        }
示例#21
0
        public void copy_directory()
        {
            var system = new FileSystem();

            system.ResetDirectory("dagobah");
            system.WriteStringToFile("dagobah".AppendPath("f1", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f2", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f3", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "f1b", "a.txt"), "something");
            system.WriteStringToFile("dagobah".AppendPath("a.txt"), "something");

            system.DeleteDirectory("rhenvar");
            system.Copy("dagobah", "rhenvar");

            system.FindFiles("rhenvar", FileSet.Everything()).Select(x => x.PathRelativeTo("rhenvar")).OrderBy(x => x)
                .ShouldHaveTheSameElementsAs(
                    "a.txt",
                    FileSystem.Combine("f1", "a.txt"),
                    FileSystem.Combine("f1", "f1a", "a.txt"),
                    FileSystem.Combine("f1", "f1a", "f1b", "a.txt"),
                    FileSystem.Combine("f2", "a.txt"),
                    FileSystem.Combine("f3", "a.txt")
                );
        }
        public void SetUp()
        {
            var system = new FileSystem();
            system.DeleteDirectory("geonosis");
            system.CreateDirectory("geonosis");

            var data1 = newData();
            var data2 = newData();
            var data3 = newData();
            var data4 = newData();
            var data5 = newData();
            var data6 = newData();
            var data7 = newData();

            saveData(data1, "a", "a1");
            saveData(data2, "a", "a2");
            saveData(data3, "b", "b3");
            saveData(data4, "b", "b4");
            saveData(data5, "c", "c5");
            saveData(data6, "c", "c6");
            saveData(data7, "c", "c7");

            theCache = new PackageFilesCache();
            theCache.AddDirectory(FileSystem.Combine("geonosis", "a"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "b"));
            theCache.AddDirectory(FileSystem.Combine("geonosis", "c"));
        }
示例#23
0
文件: Program.cs 项目: emiaj/bottles
 static void setupLog4Net()
 {
     var fs = new FileSystem();
     var configFolder = fs.SearchUpForDirectory(System.Environment.CurrentDirectory, "config") ?? ".";
     var log4NetFilePath = configFolder.AppendPath("log4net.config");
     Console.WriteLine("Using '{0}' for log4net.config", log4NetFilePath);
     log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4NetFilePath));
 }
 public Ps1ScaffolderLocator(IPowershellCommandInvoker commandInvoker, IPackageManager packageManager, IPackagePathResolver pathResolver, FileSystem.IFileSystem fileSystem, IScaffoldingConfigStore configStore)
 {
     _commandInvoker = commandInvoker;
     _packageManager = packageManager;
     _pathResolver = pathResolver ?? packageManager.PathResolver;
     _fileSystem = fileSystem;
     _configStore = configStore;
 }
        public void should_thrown_when_file_is_not_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, "not xml!");

            typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFile<SerializeMe>(fileName));
        }
示例#26
0
        public static void ProcessDirectives(ISolution solution)
        {
            var fileSystem = new FileSystem();
            var processor = new DirectiveProcessor(fileSystem, solution, new DirectiveRunner(fileSystem, solution),
                                                   new DirectiveParser(solution));

            processor.ProcessAll();
        }
示例#27
0
 /// <summary>
 /// Resets the current settings.
 /// </summary>
 public static void Reset()
 {
     FileSystem = new FileSystem();
     lock (LoadLock)
     {
         CurrentSettings = null;
     }
 }
 public CopyLatestBackupStorageTask(
     LatestRecentBackupQuery latestRecentBackupQuery, 
     FileSystem fileSystem, 
     BackupSettings backupSettings)
 {
     _latestRecentBackupQuery = latestRecentBackupQuery;
     _fileSystem = fileSystem;
     _backupSettings = backupSettings;
 }
        public void find_file_with_no_rakefile()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory("sd");
            fileSystem.CreateDirectory("sd");

            RakeFileTransform.FindFile("sd").ToLower()
                .ShouldEqual("sd".AppendPath("rakefile").ToFullPath().ToLower());
        }
        public static void AlterManifest(Action<PackageManifest> alteration)
        {
            var fileSystem = new FileSystem();
            var manifest = fileSystem.LoadPackageManifestFrom(StagingDirectory);

            alteration(manifest);

            fileSystem.WriteObjectToFile(StagingDirectory.AppendPath(PackageManifest.FILE), manifest);
        }
示例#31
0
        public static FileAttributes GetAttributes(string path)
        {
            string fullPath = Path.GetFullPath(path);

            return(FileSystem.GetAttributes(fullPath));
        }
示例#32
0
        public static void SetAttributes(string path, FileAttributes fileAttributes)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.SetAttributes(fullPath, fileAttributes);
        }
示例#33
0
 public override void Delete()
 {
     FileSystem.DeleteFile(FullPath);
     Invalidate();
 }
        public static void SetLastAccessTime(string path, DateTime lastAccessTime)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.SetLastAccessTime(fullPath, lastAccessTime, asDirectory: true);
        }
        public static void SetCreationTime(string path, DateTime creationTime)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.SetCreationTime(fullPath, creationTime, asDirectory: true);
        }
示例#36
0
        public static DateTime GetLastAccessTime(string path)
        {
            string fullPath = Path.GetFullPath(path);

            return(FileSystem.GetLastAccessTime(fullPath).LocalDateTime);
        }
示例#37
0
 private static void SetUnixFileModeCore(string path, UnixFileMode mode)
 => FileSystem.SetUnixFileMode(Path.GetFullPath(path), mode);
示例#38
0
 private static void SetUnixFileModeCore(SafeFileHandle fileHandle, UnixFileMode mode)
 => FileSystem.SetUnixFileMode(fileHandle, mode);
示例#39
0
 private static UnixFileMode GetUnixFileModeCore(string path)
 => FileSystem.GetUnixFileMode(Path.GetFullPath(path));
        public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.SetCreationTime(fullPath, File.GetUtcDateTimeOffset(creationTimeUtc), asDirectory: true);
        }
示例#41
0
        public static DateTime GetLastWriteTimeUtc(string path)
        {
            string fullPath = Path.GetFullPath(path);

            return(FileSystem.GetLastWriteTime(fullPath).UtcDateTime);
        }
 public void Refresh()
 {
     // This should not throw, instead we store the result so that we can throw it
     // when someone actually accesses a property
     _dataInitialized = FileSystem.FillAttributeInfo(FullPath, ref _data, returnErrorOnNotFound: false);
 }
示例#43
0
        public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.SetLastWriteTime(fullPath, GetUtcDateTimeOffset(lastWriteTimeUtc), asDirectory: false);
        }
 public static string[] GetLogicalDrives()
 {
     return(FileSystem.GetLogicalDrives());
 }
示例#45
0
 internal static bool InternalExists(string path)
 {
     return(FileSystem.FileExists(path));
 }
示例#46
0
 private static UnixFileMode GetUnixFileModeCore(SafeFileHandle fileHandle)
 => FileSystem.GetUnixFileMode(fileHandle);
        public static void Delete(string path)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.RemoveDirectory(fullPath, false);
        }
        public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.SetLastAccessTime(fullPath, File.GetUtcDateTimeOffset(lastAccessTimeUtc), asDirectory: true);
        }
        public static void Delete(string path, bool recursive)
        {
            string fullPath = Path.GetFullPath(path);

            FileSystem.RemoveDirectory(fullPath, recursive);
        }
示例#50
0
 public override void Delete() => FileSystem.DeleteFile(FullPath);