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"); }); }
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); }
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(); }
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" }; }
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); }
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()); }); }); }
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); }
/// <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; }
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(); }
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(); }
public AssemblyInfo(CodeFile codeFile, CsProjFile projFile) { _codeFile = codeFile; _projFile = projFile; this._fileSystem = new FileSystem(); this.Initialize(); }
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)); }
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); }); }
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()); }); }); }
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")); }
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)); }
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(); }
/// <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); }
public static FileAttributes GetAttributes(string path) { string fullPath = Path.GetFullPath(path); return(FileSystem.GetAttributes(fullPath)); }
public static void SetAttributes(string path, FileAttributes fileAttributes) { string fullPath = Path.GetFullPath(path); FileSystem.SetAttributes(fullPath, fileAttributes); }
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); }
public static DateTime GetLastAccessTime(string path) { string fullPath = Path.GetFullPath(path); return(FileSystem.GetLastAccessTime(fullPath).LocalDateTime); }
private static void SetUnixFileModeCore(string path, UnixFileMode mode) => FileSystem.SetUnixFileMode(Path.GetFullPath(path), mode);
private static void SetUnixFileModeCore(SafeFileHandle fileHandle, UnixFileMode mode) => FileSystem.SetUnixFileMode(fileHandle, mode);
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); }
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); }
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()); }
internal static bool InternalExists(string path) { return(FileSystem.FileExists(path)); }
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); }
public override void Delete() => FileSystem.DeleteFile(FullPath);