public ParsedPath(LargeFileSystem fs, string physicalFilePath, FileSystemEntity?physicalEntity = null) { this.LargeFileSystem = fs; this.PhysicalEntity = physicalEntity; this.PhysicalFilePath = physicalFilePath; string dir = fs.PathParser.GetDirectoryName(physicalFilePath); string fn = fs.PathParser.GetFileName(physicalFilePath); int[] indexes = fn._FindStringIndexes(fs.Params.SplitStr); if (indexes.Length != 1) { throw new ArgumentException($"Filename '{fn}' is not a large file. indexes.Length != 1."); } string originalFileName = fn.Substring(0, indexes[0]); string afterOriginalFileName = fn.Substring(indexes[0] + fs.Params.SplitStr.Length); if (afterOriginalFileName._IsEmpty()) { throw new ArgumentException($"Filename '{fn}' is not a large file."); } string extension; int dotIndex = afterOriginalFileName.IndexOf('.'); string digitsStr; if (dotIndex != -1) { extension = afterOriginalFileName.Substring(dotIndex); digitsStr = afterOriginalFileName.Substring(0, dotIndex); } else { extension = ""; digitsStr = afterOriginalFileName; } if (digitsStr._IsNumber() == false) { throw new ArgumentException($"Filename '{fn}' is not a large file. digitsStr.IsNumber() == false."); } if (digitsStr.Length != fs.Params.NumDigits) { throw new ArgumentException($"Filename '{fn}' is not a large file. digitsStr.Length != fs.Params.NumDigits."); } this.DirectoryPath = dir; this.OriginalFileNameWithoutExtension = originalFileName; this.FileNumber = digitsStr._ToInt(); this.Extension = extension; string filename = $"{OriginalFileNameWithoutExtension}{Extension}"; this.LogicalFilePath = fs.PathParser.Combine(this.DirectoryPath, filename); }
public static async Task <FileObject> CreateFileAsync(LargeFileSystem fileSystem, FileParameters fileParams, LargeFileSystem.ParsedPath[] relatedFiles, CancellationToken cancel = default) { cancel.ThrowIfCancellationRequested(); LargeFileObject f = new LargeFileObject(fileSystem, fileParams, relatedFiles); try { await f.InternalInitAsync(cancel); } catch { f._DisposeSafe(); throw; } return(f); }
public ParsedPath(LargeFileSystem fs, string logicalFilePath, long fileNumber) { this.LargeFileSystem = fs; this.LogicalFilePath = logicalFilePath; string fileName = fs.PathParser.GetFileName(logicalFilePath); if (fileName.IndexOf(fs.Params.SplitStr) != -1) { throw new ApplicationException($"The original filename '{fileName}' contains '{fs.Params.SplitStr}'."); } string dir = fs.PathParser.GetDirectoryName(logicalFilePath); string filename = fs.PathParser.GetFileName(logicalFilePath); string extension; int dotIndex = fileName.IndexOf('.'); string filenameWithoutExtension; if (dotIndex != -1) { extension = fileName.Substring(dotIndex); filenameWithoutExtension = fileName.Substring(0, dotIndex); } else { extension = ""; filenameWithoutExtension = fileName; } this.DirectoryPath = dir; this.OriginalFileNameWithoutExtension = filenameWithoutExtension; this.FileNumber = fileNumber; this.Extension = extension; this.PhysicalFilePath = GeneratePhysicalPath(); }
static void ModuleInit() { Local = new LargeFileSystem(new LargeFileSystemParams(LocalFileSystem.Local)); LocalUtf8 = new LargeFileSystem(new LargeFileSystemParams(LocalFileSystem.LocalUtf8)); }
protected LargeFileObject(FileSystem fileSystem, FileParameters fileParams, LargeFileSystem.ParsedPath[] relatedFiles) : base(fileSystem, fileParams) { this.LargeFileSystem = (LargeFileSystem)fileSystem; this.UnderlayFileSystem = this.LargeFileSystem.UnderlayFileSystem; this.InitialRelatedFiles = relatedFiles; }