private ImageStoreFile ConvertToImageStoreFile(string fullFilePath, string storeSource) { return(new ImageStoreFile( this.GetStoreRelativePathFromFullName(fullFilePath, storeSource), string.Empty, FabricFile.GetSize(fullFilePath), FabricFile.GetLastWriteTime(fullFilePath))); }
/// <summary> /// Compare two files and return true if they are different. /// </summary> /// <param name="firstFilename">The name of the first file to compare.</param> /// <param name="secondFilename">The name of the second file to compare.</param> /// <returns>True if the files are different, false otherwise </returns> public bool AreFilesDifferent(string firstFilename, string secondFilename) { this.ThrowIfDisposed(); if (this.copyFlag == CopyFlag.AtomicCopy || this.copyFlag == CopyFlag.AtomicCopySkipIfExists) { return(true); } else { return(FabricFile.Exists(firstFilename) != FabricFile.Exists(secondFilename) || FabricFile.GetSize(firstFilename) != FabricFile.GetSize(secondFilename) || FabricFile.GetLastWriteTime(firstFilename) != FabricFile.GetLastWriteTime(firstFilename)); } }
public void FabricFile_EndToEndPositive() { var folderPath = this.testPath; folderPath = this.ExtendPath(folderPath); var filePath = Path.Combine(folderPath, this.testFileName); Assert.IsTrue(filePath.Length > 260); LogHelper.Log("FabricDirectory.Create {0}", folderPath); FabricDirectory.CreateDirectory(folderPath); LogHelper.Log("FabricFile.Create {0}", filePath); using (StreamWriter streamWriter = new StreamWriter(FabricFile.Create(filePath))) { LogHelper.Log("Write {0}", this.testString); streamWriter.WriteLine(this.testString); } LogHelper.Log("FabricDirectory.GetDirectories {0}", this.testPath); var result = FabricDirectory.GetDirectories(this.testPath); Assert.AreEqual(1, result.Length); LogHelper.Log("FabricDirectory.GetFiles {0}", this.testPath); result = FabricDirectory.GetFiles(this.testPath); Assert.AreEqual(0, result.Length); LogHelper.Log("FabricDirectory.GetFiles {0}, AllDirectories", this.testPath); result = FabricDirectory.GetFiles(this.testPath, "*", SearchOption.AllDirectories); Assert.AreEqual(1, result.Length); LogHelper.Log("FabricDirectory.GetDirectories {0}", folderPath); result = FabricDirectory.GetDirectories(folderPath); Assert.AreEqual(0, result.Length); LogHelper.Log("FabricDirectory.GetFiles {0}", folderPath); result = FabricDirectory.GetFiles(folderPath); Assert.AreEqual(1, result.Length); LogHelper.Log("FabricFile.Open {0}", filePath); using (StreamReader streamReader = new StreamReader(FabricFile.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None))) { string actual = streamReader.ReadLine(); LogHelper.Log("Read {0}", actual); Assert.AreEqual(this.testString, actual); } LogHelper.Log("FabricFile.GetSize {0}", filePath); long size = FabricFile.GetSize(filePath); Assert.IsTrue(size > 0); LogHelper.Log("FabricPath.GetDirectoryName {0}", filePath); string directoryName = FabricPath.GetDirectoryName(filePath); Assert.AreEqual(folderPath, directoryName); LogHelper.Log("FabricFile.GetLastWriteTime {0}", filePath); DateTime oldTime = FabricFile.GetLastWriteTime(filePath); Thread.Sleep(TimeSpan.FromSeconds(1)); using (StreamWriter streamWriter = new StreamWriter(FabricFile.Open(filePath, FileMode.Open, FileAccess.Write))) { LogHelper.Log("Write {0}", this.testString); streamWriter.WriteLine(this.testString); } DateTime newTime = FabricFile.GetLastWriteTime(filePath); Assert.IsTrue(newTime > oldTime); }