public static Copy ( string src, string dst, bool overwrite = false ) : void | ||
src | string | |
dst | string | |
overwrite | bool | |
Résultat | void |
private bool UpdateInCache(Uri uri, string withFile) { using (var progressHandler = EmulationManager.Instance.ProgressMonitor.Start("Updating cache")) { lock (CacheDirectory) { var index = ReadBinariesIndex(); BinaryEntry entry; var fileId = 0; if (!index.TryGetValue(uri, out entry)) { foreach (var element in index) { fileId = Math.Max(fileId, element.Value.Index) + 1; } } else { fileId = entry.Index; } FileCopier.Copy(withFile, GetBinaryFileName(fileId), true); long size; var checksum = GetChecksumAndSizeFromUri(uri, out size); entry = new BinaryEntry(fileId, size, checksum); if (!Verify(withFile, entry)) { return(false); } index[uri] = entry; WriteBinariesIndex(index); return(true); } } }
public void Load(FileStream stream) { using (var reader = new PrimitiveReader(stream, false)) { foreach (var provider in providers) { var tempFile = TemporaryFilesManager.Instance.GetTemporaryFile(); if (ConfigurationManager.Instance.Get("file-system", "use-cow", false)) { FileCopier.Copy(stream.Name, tempFile, true); var size = reader.ReadInt64(); var localPosition = stream.Position; reader.ReadBytes((int)size); provider.BlobIsReady(tempFile, localPosition, size); } else { var size = reader.ReadInt64(); using (var fileStream = new FileStream(tempFile, FileMode.OpenOrCreate)) { reader.CopyTo(fileStream, size); } provider.BlobIsReady(tempFile, 0, size); } } } }
private bool TryGetFromCache(Uri uri, out string fileName) { lock (CacheDirectory) { fileName = null; var index = ReadBinariesIndex(); BinaryEntry entry; if (!index.TryGetValue(uri, out entry)) { return(false); } var fileToCopy = GetBinaryFileName(entry.Index); if (!Verify(fileToCopy, entry)) { return(false); } fileName = TemporaryFilesManager.Instance.GetTemporaryFile(); FileCopier.Copy(GetBinaryFileName(entry.Index), fileName, true); return(true); } }