public void FromJson(BonDocument json) { foreach (BonElement p in json) { switch (p.name) { case "dlcType": { dlcType = (DLCType)p.value.AsInt; break; } case "files": { foreach (BonElement pp in p.value.AsBonDocument) { FileDesc fd = new FileDesc(); fd.name = pp.name; fd.pak = this; files[fd.name] = fd; fd.FromJson(pp.value.AsBonDocument); } break; } case "dependences": { BonArray arr = p.value.AsBonArray; dependences = new string[arr.Count]; for (int i = dependences.Length; --i >= 0;) { dependences[i] = arr[i].AsString; } break; } } } }
public override async Task <List <string> > GetLabels(string proj) { List <string> fileList = new List <string>(); try { List <FileDesc> fdList = new List <FileDesc>(); var dir = Path.Combine(options.File, proj); if (Directory.Exists(dir)) { var files = Directory.GetFiles(dir); foreach (var file in files) { FileInfo fi = new FileInfo(file); FileDesc fd = new FileDesc { FileName = fi.Name, Length = fi.Length, ModifyTime = fi.LastWriteTime }; fdList.Add(fd); } } var orders = fdList.OrderByDescending(f => f.ModifyTime); foreach (var od in orders) { fileList.Add(JsonConvert.SerializeObject(od)); } } catch (Exception ex) { logger.LogError(ex.Message, ex); } return(fileList); }
private void Item_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListViewItem s = sender as ListViewItem; FileDesc desc = s.Content as FileDesc; Path = desc.Path; }
private void Item_Selected(object sender, RoutedEventArgs e) { // Все это надо, только если стоит галочка показывать превью if (ShowPreview.IsChecked.HasValue && !ShowPreview.IsChecked.Value) { return; } ListViewItem item = sender as ListViewItem; FileDesc fileDesc = item.Content as FileDesc; if (fileDesc != null && fileDesc.FileType == FileDesc.Type.File) { string preview = GetPreview(fileDesc.Path); if (preview != null) { PreviewTextBoxEmpty.Visibility = Visibility.Hidden; PreviewTextBox.Visibility = Visibility.Visible; PreviewTextBox.Text = preview; } else { PreviewTextBoxEmpty.Visibility = Visibility.Visible; PreviewTextBox.Visibility = Visibility.Hidden; } } else { PreviewTextBoxEmpty.Visibility = Visibility.Visible; PreviewTextBox.Visibility = Visibility.Hidden; } }
private void ScanFile(string filePath, List <FileDesc> files) { string fileName = Path.GetFileName(filePath); DateTime dtFile = GetFileCreationDate(filePath); string ext = Path.GetExtension(filePath).ToLower(); string fileDirPath = Path.GetDirectoryName(filePath); var fileDesc = new FileDesc { Path = filePath, FileName = fileName, Extension = ext, Date = dtFile, }; files.Add(fileDesc); DateTime dtNow = DateTime.UtcNow; if (dtNow > lastMessage.AddSeconds(1)) { ctrOutput.AddLine(string.Format("Detected {0} files", files.Count)); lastMessage = dtNow; } }
public override Int32 GetFileInfo( Object FileNode, Object FileDesc0, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; return(FileDesc.GetFileInfo(out FileInfo)); }
public override Int32 CanDelete( Object FileNode, Object FileDesc0, String FileName) { FileDesc FileDesc = (FileDesc)FileDesc0; FileDesc.SetDisposition(false); return(STATUS_SUCCESS); }
public override Int32 GetSecurity( Object FileNode, Object FileDesc0, ref Byte[] SecurityDescriptor) { FileDesc FileDesc = (FileDesc)FileDesc0; SecurityDescriptor = FileDesc.GetSecurityDescriptor(); return(STATUS_SUCCESS); }
//获取服务器版本名称 private string getVersionName() { try { CdnRefresh(); // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey // 实际应用中,请自行设置您的AccessKey和SecretKey Mac mac = new Mac(AppCode.AK, AppCode.SK); string bucket = "mydb"; string marker = ""; // 首次请求时marker必须为空 string prefix = null; // 按文件名前缀保留搜索结果 string delimiter = null; // 目录分割字符(比如"/") int limit = 100; // 单次列举数量限制(最大值为1000) BucketManager bm = new BucketManager(mac); List <FileDesc> items = new List <FileDesc>(); ListResult result = bm.ListFiles(bucket, prefix, marker, limit, delimiter); JavaScriptSerializer js = new JavaScriptSerializer(); object obj = js.DeserializeObject(result.Text); Dictionary <string, object> jd = (obj as Dictionary <string, object>); object[] dteil = (object[])jd["items"]; for (int i = 0; i < dteil.Length; i++) { Dictionary <string, object> li = dteil[i] as Dictionary <string, object>; FileDesc fd = new FileDesc(); fd.Key = li["key"].ToString(); fd.Fsize = (int)li["fsize"]; fd.Hash = li["hash"].ToString(); fd.MimeType = li["mimeType"].ToString(); fd.PutTime = (long)li["putTime"]; items.Add(fd); } for (int i = 0; i < items.Count; i++) { //判断名称里是否包含 Version 例:Version0 if (items[i].Key.IndexOf("version") >= 0) { return(items[i].Key); } } return(""); } catch (Exception ep) { return(""); } }
public override Int32 SetSecurity( Object FileNode, Object FileDesc0, AccessControlSections Sections, Byte[] SecurityDescriptor) { FileDesc FileDesc = (FileDesc)FileDesc0; FileDesc.SetSecurityDescriptor(Sections, SecurityDescriptor); return(STATUS_SUCCESS); }
private void Item_ButtonDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { ListViewItem s = sender as ListViewItem; FileDesc desc = s.Content as FileDesc; Path = desc.Path; e.Handled = true; // Чтоб не отдавался ентер на дефолтную кнопку } }
public override void Close( Object FileNode, Object FileDesc0) { FileDesc FileDesc = (FileDesc)FileDesc0; if (null != FileDesc.Stream) { FileDesc.Stream.Dispose(); } }
public override Int32 Rename( Object FileNode, Object FileDesc0, String FileName, String NewFileName, Boolean ReplaceIfExists) { FileName = ConcatPath(FileName); NewFileName = ConcatPath(NewFileName); FileDesc.Rename(FileName, NewFileName, ReplaceIfExists); return(STATUS_SUCCESS); }
bool Seem(FileDesc _a, FileDesc _b) { if (_a == null) { return(false); } if (_b == null) { return(false); } return(_a.targetInstaneId == _b.targetInstaneId); }
public override Int32 SetBasicInfo( Object FileNode, Object FileDesc0, UInt32 FileAttributes, UInt64 CreationTime, UInt64 LastAccessTime, UInt64 LastWriteTime, UInt64 ChangeTime, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; FileDesc.SetBasicInfo(FileAttributes, CreationTime, LastAccessTime, LastWriteTime); return(FileDesc.GetFileInfo(out FileInfo)); }
public override Int32 Flush( Object FileNode, Object FileDesc0, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; if (null == FileDesc) { /* we do not flush the whole volume, so just return SUCCESS */ FileInfo = default(FileInfo); return(STATUS_SUCCESS); } FileDesc.Stream.Flush(true); return(FileDesc.GetFileInfo(out FileInfo)); }
public override async Task <List <string> > GetLabels(string proj) { var collections = new List <string>(); var result = await client.GetDatabase(proj).ListCollectionNamesAsync(); foreach (var od in result.ToList()) { FileDesc fd = new FileDesc { FileName = od, Length = 0, ModifyTime = DateTime.Now }; collections.Add(JsonConvert.SerializeObject(fd)); } return(collections); }
public override void Cleanup( Object FileNode, Object FileDesc0, String FileName, UInt32 Flags) { FileDesc FileDesc = (FileDesc)FileDesc0; if (0 != (Flags & CleanupDelete)) { FileDesc.SetDisposition(true); if (null != FileDesc.Stream) { FileDesc.Stream.Dispose(); } } }
private void buttonOK_Click(object sender, RoutedEventArgs e) { FileDesc desc = listView1.SelectedItem as FileDesc; if (desc != null) { if (desc.FileType != FileDesc.Type.File) { //OpenPath(desc.Path); Path = desc.Path; } else { OnSelectFile(); DialogResult = true; } } }
public override Int32 Open( String FileName, UInt32 CreateOptions, UInt32 GrantedAccess, out Object FileNode, out Object FileDesc0, out FileInfo FileInfo, out String NormalizedName) { FileDesc FileDesc = null; try { FileName = ConcatPath(FileName); if (!Directory.Exists(FileName)) { FileDesc = new FileDesc( new FileStream( FileName, FileMode.Open, (FileSystemRights)GrantedAccess, FileShare.Read | FileShare.Write | FileShare.Delete, 4096, 0)); } else { FileDesc = new FileDesc( new DirectoryInfo(FileName)); } FileNode = default(Object); FileDesc0 = FileDesc; NormalizedName = default(String); return(FileDesc.GetFileInfo(out FileInfo)); } catch { if (null != FileDesc && null != FileDesc.Stream) { FileDesc.Stream.Dispose(); } throw; } }
public FileDesc[] EnumerateTopFiles(string path, params string[] extensions) { var results = new List <FileDesc>(); string[] files; if (extensions.Length == 0 || extensions[0] == AnyPattern) { files = Directory .EnumerateFiles(path, AnyPattern, SearchOption.TopDirectoryOnly) .OrderBy(f => f) .ToArray(); } else { files = Directory .EnumerateFiles(path, AnyPattern, SearchOption.TopDirectoryOnly) .Where(f => extensions.Contains(Path.GetExtension(f))) .OrderBy(f => f) .ToArray(); } foreach (var file in files) { var fi = new FileInfo(file); if (!fi.Exists) { continue; } var item = new FileDesc { FullPath = fi.FullName, Name = fi.Name, ParentDirectory = fi.Directory?.FullName }; results.Add(item); } return(results.ToArray()); }
public override Int32 SetFileSize( Object FileNode, Object FileDesc0, UInt64 NewSize, Boolean SetAllocationSize, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; if (!SetAllocationSize || (UInt64)FileDesc.Stream.Length > NewSize) { /* * "FileInfo.FileSize > NewSize" explanation: * Ptfs does not support allocation size. However if the new AllocationSize * is less than the current FileSize we must truncate the file. */ FileDesc.Stream.SetLength((Int64)NewSize); } return(FileDesc.GetFileInfo(out FileInfo)); }
public override Int32 Read( Object FileNode, Object FileDesc0, IntPtr Buffer, UInt64 Offset, UInt32 Length, out UInt32 PBytesTransferred) { FileDesc FileDesc = (FileDesc)FileDesc0; if (Offset >= (UInt64)FileDesc.Stream.Length) { ThrowIoExceptionWithNtStatus(STATUS_END_OF_FILE); } Byte[] Bytes = new byte[Length]; FileDesc.Stream.Seek((Int64)Offset, SeekOrigin.Begin); PBytesTransferred = (UInt32)FileDesc.Stream.Read(Bytes, 0, Bytes.Length); Marshal.Copy(Bytes, 0, Buffer, Bytes.Length); return(STATUS_SUCCESS); }
public override Int32 Overwrite( Object FileNode, Object FileDesc0, UInt32 FileAttributes, Boolean ReplaceFileAttributes, UInt64 AllocationSize, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; if (ReplaceFileAttributes) { FileDesc.SetFileAttributes(FileAttributes); } else if (0 != FileAttributes) { FileDesc.SetFileAttributes(FileDesc.GetFileAttributes() | FileAttributes); } FileDesc.Stream.SetLength(0); return(FileDesc.GetFileInfo(out FileInfo)); }
public override Int32 Write( Object FileNode, Object FileDesc0, IntPtr Buffer, UInt64 Offset, UInt32 Length, Boolean WriteToEndOfFile, Boolean ConstrainedIo, out UInt32 PBytesTransferred, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; if (ConstrainedIo) { if (Offset >= (UInt64)FileDesc.Stream.Length) { PBytesTransferred = default(UInt32); FileInfo = default(FileInfo); return(STATUS_SUCCESS); } if (Offset + Length > (UInt64)FileDesc.Stream.Length) { Length = (UInt32)((UInt64)FileDesc.Stream.Length - Offset); } } Byte[] Bytes = new byte[Length]; Marshal.Copy(Buffer, Bytes, 0, Bytes.Length); if (!WriteToEndOfFile) { FileDesc.Stream.Seek((Int64)Offset, SeekOrigin.Begin); } FileDesc.Stream.Write(Bytes, 0, Bytes.Length); PBytesTransferred = (UInt32)Bytes.Length; return(FileDesc.GetFileInfo(out FileInfo)); }
//检测版本 private string CheckVersion() { try { CdnRefresh(); // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey // 实际应用中,请自行设置您的AccessKey和SecretKey Mac mac = new Mac(AppCode.AK, AppCode.SK); string bucket = "mydb"; string marker = ""; // 首次请求时marker必须为空 string prefix = null; // 按文件名前缀保留搜索结果 string delimiter = null; // 目录分割字符(比如"/") int limit = 100; // 单次列举数量限制(最大值为1000) BucketManager bm = new BucketManager(mac); List <FileDesc> items = new List <FileDesc>(); ListResult result = bm.ListFiles(bucket, prefix, marker, limit, delimiter); JavaScriptSerializer js = new JavaScriptSerializer(); object obj = js.DeserializeObject(result.Text); Dictionary <string, object> jd = (obj as Dictionary <string, object>); object[] dteil = (object[])jd["items"]; for (int i = 0; i < dteil.Length; i++) { Dictionary <string, object> li = dteil[i] as Dictionary <string, object>; FileDesc fd = new FileDesc(); fd.Key = li["key"].ToString(); fd.Fsize = (int)li["fsize"]; fd.Hash = li["hash"].ToString(); fd.MimeType = li["mimeType"].ToString(); fd.PutTime = (long)li["putTime"]; items.Add(fd); } for (int i = 0; i < items.Count; i++) { //判断名称里是否包含 Version 例:Version0 if (items[i].Key.IndexOf("version") >= 0) { string Version = items[i].Key.Substring(7); Version = Version.Substring(0, Version.Length - 4); int dbversion = dal.ExecuteInt("Select VersionID From Version"); if (Convert.ToInt32(Version) > dbversion) { //需更新版本 // DownLoadSQLite(); return("需更新版本"); } else if (Convert.ToInt32(Version) == dbversion) { //最新版本 //Alert(""); return("最新版本"); } else if (Convert.ToInt32(Version) < dbversion) { //Alert(""); return("请上传版本"); } } } return("出现异常,不该访问到的代码!"); } catch (Exception ep) { return(ep.Message); } }
void OnDrawList(int _id) { if (GUILayout.Button("Pickup Path")) { string path = ""; foreach (var v in Selection.objects) { path = AssetDatabase.GetAssetPath(v); if (!string.IsNullOrEmpty(path)) { int nameLen = Path.GetFileName(path).Length; PathRoot = path.Remove(path.Length - nameLen - 1, nameLen + 1); PathRoot = PathRoot.Substring(6); Debug.Log(PathRoot); break; } } } GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Path:", GUILayout.MaxWidth(50)); PathRoot = GUILayout.TextField(PathRoot); if (GUILayout.Button("Search", GUILayout.MaxWidth(listRect.width / 4f))) { SearchListFile(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Search:", GUILayout.MaxWidth(50)); string nextSearch = GUILayout.TextField(SearchFile); GUILayout.EndHorizontal(); if (nextSearch != SearchFile) { SearchFile = nextSearch; FileFilter.Clear(); if (SearchFile != "") { foreach (var v in Files) { if (v.name.Contains(SearchFile)) { FileFilter.Add(v); } } } } var show = SearchFile.Length > 0 ? FileFilter : Files; ListScrollViewPos = GUILayout.BeginScrollView(ListScrollViewPos); GUILayout.BeginVertical(); float normal = listRect.width / 4 * 3; float select = listRect.width; foreach (var v in show) { bool seem = Seem(Select, v); if (GUILayout.Button(v.name, GUILayout.MaxWidth(seem ? select:normal))) { if (!seem) { Select = v; TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(AssetDatabase.GetAssetPath(v.targetInstaneId)); if (asset != null) { string tableKey = v.targetInstaneId.ToString(); Storage.LoadData(tableKey, asset.text); Titles = Storage.GetTitle(tableKey); SetContents(Storage.Select(tableKey, "", true)); } } else { if (Seem(Focus, v)) { Focus = null; } else { Focus = v; EditorGUIUtility.PingObject(v.targetInstaneId); } } } } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (show.Count == 0) { EditorGUILayout.HelpBox("Empty", MessageType.Warning); } EditorGUILayout.HelpBox(Application.dataPath + PathRoot, MessageType.None); }
public bool FileExists(FileDesc fileDesc, FilePath options, out string filePath) => FileExists(fileDesc.Key.ToFilePart(), options, out filePath);
public static DatFileDesc ParseTextWithErrorsReturn(string text, string path, ref List<gfErrors> errors, cProject cp = null) { DatFileDesc result = null; try { Stopwatch sw = new Stopwatch(); sw.Start(); if (text.Trim().Length == 0) return null; result = new DatFileDesc() { header = new Header(), frames = new List<FrameInfo>(), regions = new List<RegionInfo>() }; errors = new List<gfErrors>(); StringReader sr = new StringReader(text); string line; int nline = 0; string oTag = ""; string cTag = ""; RegionInfo cri = null; WeaponStrListInfoEntry wsl = null; bool isRegion = false; bool isRegionend = false; while ((line = sr.ReadLine()) != null) { nline++; line = line.Trim(); if (line.Length == 0) continue; //--------------------------------------------------------------------------------------------------------------------------------- if (line.Contains("#region")) { cri = new RegionInfo(); isRegion = true; oTag = "#region"; string[] astr = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (astr.Length > 1) cri.caption = astr[1]; cri.oline = nline; result.regions.Add(cri); // continue; } if (line.Contains("#endregion")) { cTag = "#endregion"; if (oTag != "#region") errors.Add(new gfErrors("Closing tag #endregion found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; cri.cline = nline; continue; } if (line == "<bmp_begin>") { result.header.foldcaption = line; result.header.oline = nline; oTag = "<bmp_begin>"; continue; } if (line == "<weapon_strength_list>") { result.wsl_oline = nline; if (cTag != "<bmp_end>") errors.Add(new gfErrors("Closing tag <bmp_end> expected", nline, path, Utils.Project.GetNameProject(cp))); oTag = "<weapon_strength_list>"; continue; } if (line.Contains("<frame>") || line == "<frame_end>") { if (oTag == "<bmp_begin>") errors.Add(new gfErrors("Closing tag <bmp_end> expected", nline, path, Utils.Project.GetNameProject(cp))); if (oTag == "<weapon_strength_list>") errors.Add(new gfErrors("Closing tag <weapon_strength_list_end> expected", nline, path, Utils.Project.GetNameProject(cp))); oTag = "frame"; break; } //--------------------------------------------------------------------------------------------------------------------------------- if (line == "<bmp_end>") { if (result.header.cline==-1) result.header.cline = nline; cTag = "<bmp_end>"; if (oTag != "<bmp_begin>" && oTag != "#region") errors.Add(new gfErrors("Closing tag <bmp_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "<weapon_strength_list_end>") { result.wsl_cline = nline; cTag = "<weapon_strength_list_end>"; if (oTag != "<weapon_strength_list>") errors.Add(new gfErrors("Closing tag <weapon_strength_list_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); if (oTag == "<bmp_begin>") errors.Add(new gfErrors("Closing tag <bmp_end> expected", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; break; } //----------------------------------------Parsing----------------------------------------------------------------------------------------- if (oTag == "<bmp_begin>") { #region Parse bmp_begin if (line.Contains("file")) { FileDesc fd = new FileDesc(); string st = GetTextBetweenBraces(line); string[] s2 = st.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (s2.Length > 1) { try { fd.firstFrame = Convert.ToInt32(s2[0]); fd.lastFrame = Convert.ToInt32(s2[1]); } catch { } } List<PropDesc> pd = GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag); if (pd.Count > 0) fd.path = pd[0].value; for (int i = 1; i < pd.Count; i++) { try { switch (pd[i].name) { case "w:": fd.width = Convert.ToInt32(pd[i].value); break; case "h:": fd.height = Convert.ToInt32(pd[i].value); break; case "row:": fd.col = Convert.ToInt32(pd[i].value); break; case "col:": fd.row = Convert.ToInt32(pd[i].value); break; } } catch { } } result.header.files.Add(fd); } else { PropDesc pd = GetProperty(line); result.header.properties.Add(pd); if (pd.name != null && pd.value != null) { if (!pd.name.Contains("sound") && !pd.name.Contains("file") && pd.name != "name:" && pd.name != "head:" && pd.name != "small:") { if (!isStringConsistsDigits(pd.value)) errors.Add(new gfErrors("Number value expected", nline, path, Utils.Project.GetNameProject(cp))); } } } #endregion continue; } if (oTag == "<weapon_strength_list>") { #region Parse weapon_strength_list block if (line.Contains("entry:")) { wsl = new WeaponStrListInfoEntry(); string[] st3 = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); wsl.number = Convert.ToInt32(st3[1]); } else { if (wsl != null) { wsl.props.AddRange(GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag)); result.wsl.Add(wsl); } } #endregion continue; } //--------------------------------------End parsing----------------------------------------------------------------------------------------- if (line == "<bmp_end>") { if (oTag != "<bmp_begin>") errors.Add(new gfErrors("Closing tag <bmp_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "<weapon_strength_list_end>") { if (oTag != "<weapon_strength_list>") errors.Add(new gfErrors("Closing tag <weapon_strength_list_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } } if (line == null) return result; //---------------------------------------End parsing frame_begin and weapon list------------------------------------------------------------------------------------------ if (result.header.files.Count > 0) { firstPic = result.header.files[0].firstFrame; lastPic = result.header.files[0].lastFrame; for (int i = 1; i < result.header.files.Count; i++) { if (result.header.files[i].firstFrame < firstPic) firstPic = result.header.files[i].firstFrame; if (result.header.files[i].lastFrame > lastPic) lastPic = result.header.files[i].lastFrame; } } /////////////////////////////// bool isFrame = false; bool isFrameend = false; FrameInfo cfi = null; /* bool isBpoint = false; bool isBpointend = false; bool isCpoint = false; bool isCpointend = false; bool isWpoint = false; bool isWpointend = false; bool isOpoint = false; bool isOpointend = false; bool isBdy = false; bool isBdyend = false; bool isItr = false; bool isItrend = false;*/ //FrameInfo prev = new FrameInfo(); nline--; do { nline++; line = line.Trim(); if (line.Length == 0) continue; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (line.Contains("#region") || line.Contains("<frame>") || line == "bpoint:" || line == "wpoint:" || line == "cpoint:" || line == "opoint:" || line == "bdy:" || line == "itr:" || line == "<frame_end>") { if (oTag == "bpoint:") if (cTag != "bpoint_end:") { cfi.lnst.cl_bpoint = nline - 1; errors.Add(new gfErrors("Closing tag \"bpoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "wpoint:") if (cTag != "wpoint_end:") { cfi.lnst.cl_wpoint = nline - 1; errors.Add(new gfErrors("Closing tag \"wpoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "cpoint:") if (cTag != "cpoint_end:") { cfi.lnst.cl_cpoint = nline - 1; errors.Add(new gfErrors("Closing tag \"cpoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "opoint:") if (cTag != "opoint_end:") { cfi.lnst.cl_opoint = nline - 1; errors.Add(new gfErrors("Closing tag \"opoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "bdy:") if (cTag != "bdy_end:") { cfi.lnst.cl_bdy.Add(nline - 1); errors.Add(new gfErrors("Closing tag \"bdy_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "itr:") if (cTag != "itr_end:") { cfi.lnst.cl_itr.Add(nline - 1); errors.Add(new gfErrors("Closing tag \"itr_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (line.Contains("#region")) { if (isRegion && !isRegionend) errors.Add(new gfErrors("Closing tag #endregion expected", nline, path, Utils.Project.GetNameProject(cp))); isRegion = true; isRegionend = false; oTag = "#region"; // if (cri != null) // result.regions.Add(cri); cri = new RegionInfo(); string[] astr = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (astr.Length > 1) cri.caption = astr[1]; cri.oline = nline; result.regions.Add(cri); continue; } if (line.Contains("<frame>")) { if (line.Contains("dummy")) { } if (isFrame == true && isFrameend == false) { cfi.cline = nline - 1; errors.Add(new gfErrors("Closing tag <frame_end> expected", nline, path, Utils.Project.GetNameProject(cp))); } isFrame = true; isFrameend = false; oTag = "<frame>"; if (cfi != null) { //prev = cfi; result.frames.Add(cfi); } cfi = new FrameInfo(); string[] astr = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (astr.Length > 1) try { cfi.number = Convert.ToInt32(astr[1]); } catch { cfi.number = -1; } //////////////// for (int i = 0; i < result.frames.Count; i++) { if (cfi.number == result.frames[i].number) { errors.Add(new gfErrors("Frame with this number value already exists", nline, path, Utils.Project.GetNameProject(cp))); break; } } //if (cfi.number < prev.number) // errors.Add(new gfErrors("Frame number value must be greater than number value in previous frames", nline, path, Utils.Project.GetNameProject(cp))); //////////////// if (astr.Length > 2) cfi.caption = astr[2]; else cfi.number = null; cfi.oline = nline; cfi.foldcaption = line; continue; } if (line == "bpoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "bpoint:"; cfi.lnst.ol_bpoint = nline; continue; } if (line == "wpoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "wpoint:"; cfi.lnst.ol_wpoint = nline; continue; } if (line == "bdy:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "bdy:"; cfi.lnst.ol_bdy.Add(nline); cfi.bdy.Add(new List<PropDesc>()); continue; } if (line == "itr:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "itr:"; cfi.lnst.ol_itr.Add(nline); cfi.itr.Add(new List<PropDesc>()); continue; } if (line == "cpoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "cpoint:"; cfi.lnst.ol_cpoint = nline; continue; } if (line == "opoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "opoint:"; cfi.lnst.ol_opoint = nline; continue; } ////////////////////////////////////////////////////////// #region Check errors (if open tag miss) if (line == "#endregion") { if (isRegion == false) errors.Add(new gfErrors("Found #endregion tag but where opening tag #region?", nline, path, Utils.Project.GetNameProject(cp))); isRegionend = true; oTag = ""; if (isRegion == true && isRegion == true) isRegion = false; if (cri != null) cri.cline = nline; continue; } if (line == "<frame_end>") { if (cfi.lastheaderline==-1) cfi.lastheaderline = nline - 1; if (isFrame == false) errors.Add(new gfErrors("Found <frame_end> tag but where opening tag <frame>?", nline, path, Utils.Project.GetNameProject(cp))); isFrameend = true; oTag = ""; if (isFrame == true && isFrameend == true) isFrame = false; if (cfi != null) cfi.cline = nline; // continue; } if (line == "bpoint_end:") { cfi.lnst.cl_bpoint = nline; if (oTag != "bpoint:") errors.Add(new gfErrors("Found \"bpoint_end:\" tag but where opening tag \"bpoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); //isBpoint = true; //oTag = ""; cTag = "bpoint_end:"; continue; } if (line == "wpoint_end:") { cfi.lnst.cl_wpoint = nline; if (oTag != "wpoint:") errors.Add(new gfErrors("Found \"wpoint_end:\" tag but where opening tag \"wpoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "bdy_end:") { cfi.lnst.cl_bdy.Add(nline); if (oTag != "bdy:") errors.Add(new gfErrors("Found \"bdy_end:\" tag but where opening tag \"bdy:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "itr_end:") { cfi.lnst.cl_itr.Add(nline); if (oTag != "itr:") errors.Add(new gfErrors("Found \"itr_end:\" tag but where opening tag \"itr:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "cpoint_end:") { cfi.lnst.cl_cpoint = nline; if (oTag != "cpoint:") errors.Add(new gfErrors("Found \"cpoint_end:\" tag but where opening tag \"cpoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "opoint_end:") { cfi.lnst.cl_opoint = nline; if (oTag != "opoint:") errors.Add(new gfErrors("Found \"opoint_end:\" tag but where opening tag \"opoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } #endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (oTag == "<frame>") { if (cfi.firstheaderline == -1) cfi.firstheaderline = nline; cfi.header.AddRange(GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag)); continue; } if (oTag == "bpoint:" && cfi != null) { cfi.bpoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "wpoint:" && cfi != null) { cfi.wpoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "bdy:" && cfi != null) { cfi.bdy[cfi.bdy.Count - 1].AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "itr:" && cfi != null) { cfi.itr[cfi.itr.Count - 1].AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "cpoint:" && cfi != null) { cfi.cpoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "opoint:" && cfi != null) { cfi.opoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } } while ((line = sr.ReadLine()) != null); if (isRegion == true && isRegionend == false) errors.Add(new gfErrors("Closing tag #endregion expected", nline, path, Utils.Project.GetNameProject(cp))); if (isFrame == true && isFrameend == false) errors.Add(new gfErrors("Closing tag <frame_end> expected", nline, path, Utils.Project.GetNameProject(cp))); sw.Stop(); result.frames.Add(cfi); // G.mainWindow.teOutput.AppendText // ("ParseDatFileFromString-время прошло: " + sw.ElapsedMilliseconds + " миллисекунд" + Environment.NewLine); // G.mainWindow.teOutput.ScrollToEnd(); } catch (Exception ex) { new wException(ex).ShowDialog(); } return result; }
public override Int32 Create( String FileName, UInt32 CreateOptions, UInt32 GrantedAccess, UInt32 FileAttributes, Byte[] SecurityDescriptor, UInt64 AllocationSize, out Object FileNode, out Object FileDesc0, out FileInfo FileInfo, out String NormalizedName) { FileDesc FileDesc = null; try { FileName = ConcatPath(FileName); if (0 == (CreateOptions & FILE_DIRECTORY_FILE)) { FileSecurity Security = null; if (null != SecurityDescriptor) { Security = new FileSecurity(); Security.SetSecurityDescriptorBinaryForm(SecurityDescriptor); } FileDesc = new FileDesc( new FileStream( FileName, FileMode.CreateNew, (FileSystemRights)GrantedAccess | FileSystemRights.WriteAttributes, FileShare.Read | FileShare.Write | FileShare.Delete, 4096, 0, Security)); FileDesc.SetFileAttributes(FileAttributes | (UInt32)System.IO.FileAttributes.Archive); } else { if (Directory.Exists(FileName)) { ThrowIoExceptionWithNtStatus(STATUS_OBJECT_NAME_COLLISION); } DirectorySecurity Security = null; if (null != SecurityDescriptor) { Security = new DirectorySecurity(); Security.SetSecurityDescriptorBinaryForm(SecurityDescriptor); } FileDesc = new FileDesc( Directory.CreateDirectory(FileName, Security)); FileDesc.SetFileAttributes(FileAttributes); } FileNode = default(Object); FileDesc0 = FileDesc; NormalizedName = default(String); return(FileDesc.GetFileInfo(out FileInfo)); } catch { if (null != FileDesc && null != FileDesc.Stream) { FileDesc.Stream.Dispose(); } throw; } }
public override Boolean ReadDirectoryEntry( Object FileNode, Object FileDesc0, String Pattern, String Marker, ref Object Context, out String FileName, out FileInfo FileInfo) { FileDesc FileDesc = (FileDesc)FileDesc0; if (null == FileDesc.FileSystemInfos) { if (null != Pattern) { Pattern = Pattern.Replace('<', '*').Replace('>', '?').Replace('"', '.'); } else { Pattern = "*"; } IEnumerable Enum = FileDesc.DirInfo.EnumerateFileSystemInfos(Pattern); SortedList List = new SortedList(); if (null != FileDesc.DirInfo && null != FileDesc.DirInfo.Parent) { List.Add(".", FileDesc.DirInfo); List.Add("..", FileDesc.DirInfo.Parent); } foreach (FileSystemInfo Info in Enum) { List.Add(Info.Name, Info); } FileDesc.FileSystemInfos = new DictionaryEntry[List.Count]; List.CopyTo(FileDesc.FileSystemInfos, 0); } int Index; if (null == Context) { Index = 0; if (null != Marker) { Index = Array.BinarySearch(FileDesc.FileSystemInfos, new DictionaryEntry(Marker, null), _DirectoryEntryComparer); if (0 <= Index) { Index++; } else { Index = ~Index; } } } else { Index = (int)Context; } if (FileDesc.FileSystemInfos.Length > Index) { Context = Index + 1; FileName = (String)FileDesc.FileSystemInfos[Index].Key; FileDesc.GetFileInfoFromFileSystemInfo( (FileSystemInfo)FileDesc.FileSystemInfos[Index].Value, out FileInfo); return(true); } else { FileName = default(String); FileInfo = default(FileInfo); return(false); } }
internal static int CompareFileDescByMoveIndex(FileDesc l, FileDesc r) { return (l.MoveIndex < r.MoveIndex) ? -1 : (l.MoveIndex == r.MoveIndex) ? 0 : +1; }