/// <summary>Create a new folder</summary> /// <param name="cur"></param> /// <param name="idParent">Parent folder ID</param> /// <param name="name">Folder name</param> /// <returns></returns> public static EfsEntry CreateFolder(Cursor <EfsEntry> cur, int idParent, string name) { if (name.IndexOfAny(s_PathSplitCharacters) >= 0) { throw new IOException("Invalid name"); } var ne = EfsEntry.NewFolder(idParent, name); cur.Add(ne); return(ne); }
public static EfsEntry CreateFolderEx(Cursor <EfsEntry> cur, int idParent, string path) { DirectoryInfo di = new DirectoryInfo(path); if (!di.Exists) { throw new FileNotFoundException(); } var ne = EfsEntry.NewFolder(idParent, di); cur.Add(ne); return(ne); }
public static int CreateFolderRecursively(Recordset <EfsEntry> rs, int?idParent, IEnumerable <string> components) { if (!idParent.HasValue) { idParent = m_idRootFolder; } // Find existing portion. int?id = m_idRootFolder; IEnumerator <string> e = components.GetEnumerator(); // Find existing part of the path while (true) { if (!e.MoveNext()) { return(id.Value); } int?idNext = FindFile(rs, id, e.Current); if (!idNext.HasValue) { break; } /* bool? bIsDirectory = (bool?)rs.cursor.FetchSingleField( "isDirectory" ); * if( !bIsDirectory.HasValue || !bIsDirectory.Value ) * return null; */ id = idNext; } // Create missing part of the path rs.cursor.ResetIndex(); while (true) { EfsEntry ne = EfsEntry.NewFolder(id.Value, e.Current); rs.cursor.Add(ne); id = ne.id; if (!e.MoveNext()) { return(id.Value); } } }