/// <summary> /// Copy file /// </summary> /// <param name="from">can be any valid file name - no form requirements</param> /// <returns></returns> public int cp(string from) { var newname = Os.winInternal(FullName); rm(); File.Copy(from, newname, true); #region double check if file has moved if (Ensure) { return(awaitFileMaterializing(newname)); } #endregion return(0); }
/// <summary> /// throws exception if dir is not empty /// </summary> /// <param name="path"></param> private static void rmdir(string path) { path = Os.winInternal(path); var dir = new DirectoryInfo(path); if (dir.Exists) { Directory.Delete(path); if (path.ToLower().Contains("dropbox")) { awaitDirVanishing(path); } } }
/// <summary>Create a directory if it does not exist yet</summary> /// <param name="dirname"></param> /// <returns>DirectoryInfo structure; contains properties Exists and CreationDate</returns> public static DirectoryInfo mkdir(string dirname) { dirname = Os.winInternal(string.IsNullOrEmpty(dirname) ? Directory.GetCurrentDirectory() : dirname); var dir = new DirectoryInfo(dirname); if (!dir.Exists) // TODO problems with network drives, i.e. IservSetting.RemoteRootDir { dir = Directory.CreateDirectory(dirname); if (dirname.ToLower().Contains("dropbox")) { awaitDirMaterializing(dirname); } } return(dir); }
/// <summary> /// Copy file /// </summary> /// <param name="from">will be checked; exception will be thrown if file name does not match RsbFile form requirements</param> /// <returns>0 if everything went well</returns> public int cp(RaiFile from) { // copy file in the file system var oldname = Os.winInternal(from.FullName); var newname = Os.winInternal(FullName); rm(); // make sure it's really gone before we go ahead; applies ensure File.Copy(oldname, newname, true); // overwrite if exists (which should never happen since we just removed it) #region double check if file has moved if (Ensure) { return(awaitFileMaterializing(newname)); } #endregion return(0); }
public int rm() // removes file from the file system { var name = Os.winInternal(FullName); if (File.Exists(name)) { File.Delete(name); #region double check if file is gone if (Ensure) { return(awaitFileVanishing(name)); } #endregion } return(0); }
public int mv(RaiFile from) // relocates file in the file system { //bool destIsDropbox = Name.ToLower().Contains("dropbox"); //bool srcIsDropbox = from.Name.ToLower().Contains("dropbox"); //#region both files in Dropbox - no acceleration //#endregion mkdir(); // create destdir if necessary; applies ensure var newname = Os.winInternal(FullName); var oldname = Os.winInternal(from.FullName); rm(); // make sure it's really gone before we go ahead; applies ensure File.Move(oldname, newname); // make sure the user that w3wp runs under has write/delete access to oldname, i.e. c:\dropbox\config\3.3.3\Users.xml #region double check if file has moved if (Ensure) { return(awaitFileVanishing(oldname) + awaitFileMaterializing(newname)); } #endregion return(0); }
public static string Escape(string s, EscapeMode mode) { if (mode == EscapeMode.noEsc) { return(s); } if (mode == EscapeMode.blankEsc) { return(Os.escapeBlank(s)); } if (mode == EscapeMode.paramEsc) { return(Os.escapeParam(s)); } if (mode == EscapeMode.backslashed) { return(Os.winInternal(s)); } return(s); }
/// <summary> /// Check if the file currently exists in the file system /// </summary> /// <returns></returns> public bool Exists() { return(File.Exists(Os.winInternal(FullName))); }