private DirInfo getFileInfo(EDirType dirtype, string path) { bool editable = this.canEdit(dirtype); if (UtilsHelper.GetPlatform() == EPlatform.Android) { if (dirtype == EDirType.StreamingAssetsPath) { return(null); } } var dir = getDir(dirtype); var fn = dir + path; var fileinfo = new FileInfo(path); var ifo = new DirInfo(); ifo.isdir = true; ifo.dirtype = dirtype; ifo.name = fileinfo.Name; ifo.path = path; ifo.modifytime = fileinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); ifo.editable = editable; ifo.filetype = getFileType(fileinfo.Extension); ifo.size = 0; return(ifo); }
private DirInfo getInfo(EDirType dirtype, string path) { DirInfo dirInfo = null; var fn = getDir(dirtype) + path; if (File.Exists(fn)) { dirInfo = getFileInfo(dirtype, path); } else if (Directory.Exists(fn)) { dirInfo = getDirInfo(dirtype, path); } return(dirInfo); }
private DirInfo getDirInfo(EDirType dirtype, string path) { bool editable = this.canEdit(dirtype); if (UtilsHelper.GetPlatform() == EPlatform.Android) { if (dirtype == EDirType.StreamingAssetsPath) { return(null); } } var dir = getDir(dirtype) + path; if (!Directory.Exists(dir)) { return(null); } var info = new DirInfo(); info.dirtype = dirtype; info.isdir = true; if (string.IsNullOrEmpty(path) || path == "/") { info.name = dirtype.ToString(); info.path = "/"; info.renameable = false; path = ""; } else { info.name = Path.GetFileName(path); info.path = path; info.renameable = editable; } info.editable = editable; info.filetype = getFileType(null); info.children = new List <DirInfo>(); var dirinfo = new DirectoryInfo(dir); info.modifytime = dirinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); var dirinfos = dirinfo.GetDirectories(); foreach (var di in dirinfos) { var ifo = new DirInfo(); ifo.isdir = true; ifo.dirtype = dirtype; ifo.name = di.Name; ifo.path = path + "/" + di.Name; ifo.modifytime = di.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); ifo.editable = editable; ifo.filetype = getFileType(null); ifo.renameable = editable; ifo.size = 0; info.children.Add(ifo); } var filesinfos = dirinfo.GetFiles(); foreach (var fi in filesinfos) { var filename = fi.Name.ToLower(); if (dirtype == EDirType.StreamingAssetsPath && (filename == "www.zip" || filename == "www.zip.meta")) { continue; } var ifo = new DirInfo(); ifo.isdir = false; ifo.dirtype = dirtype; ifo.name = fi.Name; ifo.path = path + "/" + fi.Name; ifo.modifytime = fi.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); ifo.editable = editable; ifo.filetype = getFileType(fi.Extension); ifo.renameable = editable; ifo.size = fi.Length; info.children.Add(ifo); } info.childnum = info.children.Count; return(info); }