public AttemptResult Rename(string new_name, bool overwrite, long milliseconds = StreamSystem.DEFAULT_WAIT) { new_name = Filename.CleanFilename(new_name); AttemptResult result = GetStreamSystem().Rename( GetPath(), new_name, overwrite, milliseconds ); if (result.IsDesired()) { if (RenameInternal(new_name)) { name = new_name; } else { this.OrphanHoldable(); } } return(result); }
static public bool IsUndesired(this AttemptResult item) { if (item.IsDesired() == false) { return(true); } return(false); }
public virtual AttemptResult MoveDirectoryForeign(string src_path, StreamSystem dst, string dst_path, bool overwrite, long milliseconds = StreamSystem.DEFAULT_WAIT) { AttemptResult result = CopyDirectoryForeign(src_path, dst, dst_path, overwrite, milliseconds); if (result.IsDesired()) { DeleteDirectory(src_path); } return(result); }
public AttemptResult Delete(long milliseconds = StreamSystem.DEFAULT_WAIT) { AttemptResult result = GetStreamSystem().Delete( GetPath(), milliseconds ); if (result.IsDesired()) { this.OrphanHoldable(); } return(result); }
static public AttemptResult Write(this StreamSystem item, string path, AttemptProcess <Stream> process, long milliseconds = StreamSystem.DEFAULT_WAIT) { Stream stream; AttemptResult result = item.OpenStreamForWriting(path, out stream, milliseconds); using (stream) { if (result.IsDesired()) { return(process(stream)); } } return(result); }
public AttemptResult Rename(string new_name, bool overwrite, long milliseconds = StreamSystem.DEFAULT_WAIT) { AttemptResult result = GetStreamSystem().Rename( GetPath(), new_name, overwrite, milliseconds ); if (result.IsDesired()) { SetName(new_name); } return(result); }
static public AttemptResult AttemptReadBytes <T>(this StreamSystem item, string path, Operation <T, byte[]> operation, out T output, long milliseconds = StreamSystem.DEFAULT_WAIT) { byte[] bytes; AttemptResult result = item.AttemptReadBytes(path, out bytes, milliseconds); if (result.IsDesired()) { output = operation(bytes); } else { output = default(T); } return(result); }
public AttemptResult MoveTo(StreamDirectory destination, bool overwrite, long milliseconds = StreamSystem.DEFAULT_WAIT) { AttemptResult result = GetStreamSystem().Move( GetPath(), destination.GetStreamSystem(), destination.GetChildPath(GetName()), overwrite, milliseconds ); if (result.IsDesired()) { SetParentDirectory(destination); } return(result); }
static public AttemptResult AttemptReadText <T>(this StreamSystem item, string path, Operation <T, string> operation, out T output, long milliseconds = StreamSystem.DEFAULT_WAIT) { T temp = default(T); AttemptResult result = item.AttemptReadText(path, delegate(string text) { temp = operation(text); }, milliseconds); if (result.IsDesired()) { output = temp; } else { output = default(T); } return(result); }
static public AttemptResult AttemptRead(this StreamSystem item, string path, TryProcess <Stream> process, long milliseconds = StreamSystem.DEFAULT_WAIT) { Stream stream; AttemptResult result = item.OpenStreamForReading(path, out stream, milliseconds); using (stream) { if (result.IsDesired()) { if (process(stream) == false) { result = AttemptResult.Failed; } } } return(result); }
static public AttemptResult AttemptReadLines <T>(this StreamSystem item, string path, Operation <T, IEnumerable <string> > operation, out T output, long milliseconds = StreamSystem.DEFAULT_WAIT) { T temp = default(T); AttemptResult result = item.AttemptReadLines(path, delegate(IEnumerable <string> lines) { temp = operation(lines); }, milliseconds); if (result.IsDesired()) { output = temp; } else { output = default(T); } return(result); }
static public AttemptResult AttemptReadRandomLine <T>(this StreamSystem item, string path, Operation <T, string> operation, out T output, RandIntSource source, long milliseconds = StreamSystem.DEFAULT_WAIT) { T temp = default(T); AttemptResult result = item.AttemptReadRandomLine(path, delegate(string line) { temp = operation(line); }, source, milliseconds); if (result.IsDesired()) { output = temp; } else { output = default(T); } return(result); }