public void LoadOption(FileFormatOption option) { if (option == null) { return; } OnLoadOption(option); }
public void BackupOption(FileFormatOption option) { if (option == null) { return; } OnBackupOption(option); }
public bool Open(FileFormatOption option, string path, bool is_append = false) { Close(); Option = option; IsOpen = OnOpenPath(option, path, is_append); return(IsOpen); }
public bool Open(FileFormatOption option, string path) { Close(); Option = option; IsOpen = OnOpenPath(option, path); return(IsOpen); }
protected virtual bool OnOpenPath(FileFormatOption option, string path) { try { BaseStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); /* 解析失敗のときはエラー */ if (!OnOpenStream(Option, BaseStream)) { Close(); return(false); } FilePath = path; return(true); } catch { Close(); return(false); } }
protected virtual bool OnOpenPath(FileFormatOption option, string path, bool is_append) { try { /* 親フォルダ生成 */ Directory.CreateDirectory(Path.GetDirectoryName(path)); BaseStream = new FileStream(path, (is_append) ? (FileMode.Append) : (FileMode.Create)); if (!OnOpenStream(Option, BaseStream)) { Close(); return(false); } FilePath = path; return(true); } catch { Close(); return(false); } }
protected virtual void OnBackupOption(FileFormatOption option) { }
protected virtual void OnLoadOption(FileFormatOption option) { }
protected virtual bool OnOpenStream(FileFormatOption option, Stream stream) { return(true); }