public static string GroupLocalDir(string localDir) { localDir = DenebolaToolkit.GetFairLocalPath(localDir, Consts.GROUP_BUNDLE_DIR); Utilities.CheckLength(localDir, Consts.GROUP_LOCAL_DIR_LEN_MIN, Consts.GROUP_LOCAL_DIR_LEN_MAX, "グループ・ローカルディレクトリ名"); return(localDir); }
public static string ToCreatableFairFullPath(string path) { path = FileTools.MakeFullPath(path); string dir = Path.GetDirectoryName(path); string localPath = Path.GetFileName(path); localPath = DenebolaToolkit.GetFairLocalPath(localPath, dir + "0123456789"); // 重複回避のため追加される文字列のためにマージンを取る。 path = Path.Combine(dir, localPath); path = ExtraTools.ToCreatablePath(path); return(path); }
private object DeleteFile() { this.LoggedIn(); Group group = this.LiteGroup.GetGroup(); string dir = Path.Combine(group.Dir, Consts.FILE_BUNDLE_LOCAL_DIR); string localFile = DenebolaToolkit.GetFairLocalPath(this.TPrm.StringValue, dir); string file = Path.Combine(dir, localFile); ProcMain.WriteLog("ファイル削除 ⇒ " + file); FileTools.Delete(file); return("OK"); }
private object Upload() { this.LoggedIn(); TrySlimdown(100); Group group = this.LiteGroup.GetGroup(); string dir = Path.Combine(group.Dir, Consts.FILE_BUNDLE_LOCAL_DIR); string localFile = DenebolaToolkit.GetFairLocalPath(this.TPrm["LocalFile"].StringValue, dir); string file = Path.Combine(dir, localFile); if (File.Exists(file) == false) { throw new Exception("指定されたファイルは存在しません。"); } long offset = long.Parse(this.TPrm["Offset"].StringValue); if (offset < 0L || LongTools.IMAX_64 < offset) { throw new Exception("不正なオフセット値です。" + offset); } byte[] data = new Base64Unit().Decode(this.TPrm["Data"].StringValue); long fileSize = new FileInfo(file).Length; if (fileSize < offset) { throw new Exception("ファイルサイズより大きなオフセット値です。" + offset); } // offset < fileSize の場合は、既に正常に書き込まれたと見なす。 if (offset == fileSize) { using (FileStream writer = new FileStream(file, FileMode.Append, FileAccess.Write)) { writer.Write(data, 0, data.Length); } } return("OK"); }
private object CreateFile() { this.LoggedIn(); TrySlimdown(10); Group group = this.LiteGroup.GetGroup(); string dir = Path.Combine(group.Dir, Consts.FILE_BUNDLE_LOCAL_DIR); string localFile = DenebolaToolkit.GetFairLocalPath(this.TPrm.StringValue, dir); string file = Path.Combine(dir, localFile); ProcMain.WriteLog("ファイル作成.1 ⇒ " + file); file = Utilities.ToCreatableFairFullPath(file); ProcMain.WriteLog("ファイル作成.2 ⇒ " + file); File.WriteAllBytes(file, BinTools.EMPTY); return(Path.GetFileName(file)); }
private object RenameFile() { this.LoggedIn(); Group group = this.LiteGroup.GetGroup(); string dir = Path.Combine(group.Dir, Consts.FILE_BUNDLE_LOCAL_DIR); string localFileOld = DenebolaToolkit.GetFairLocalPath(this.TPrm[0].StringValue, dir); string localFileNew = DenebolaToolkit.GetFairLocalPath(this.TPrm[1].StringValue, dir); string fileOld = Path.Combine(dir, localFileOld); string fileNew = Path.Combine(dir, localFileNew); bool forceMode = Utilities.GetBoolean(this.TPrm[2].StringValue); ProcMain.WriteLog("元ファイル.1 ⇒ " + fileOld); ProcMain.WriteLog("新ファイル.1 ⇒ " + fileNew); if (File.Exists(fileOld) == false) { throw new Exception("元ファイルが見つかりません。"); } if (File.Exists(fileNew)) { if (forceMode) { fileNew = Utilities.ToCreatableFairFullPath(fileNew); } else { throw new Exception("新ファイルは既に存在します。"); } } ProcMain.WriteLog("新ファイル.2 ⇒ " + fileNew); File.Move(fileOld, fileNew); return("OK"); }