protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpFileCollection uploadedFiles = Request.Files; // 다수의 파일을 다운로드 하여 파일을 저장함 for (int j = 0; j < uploadedFiles.Count; j++) { HttpPostedFile userPostedFile = uploadedFiles[j]; // 파일 내용이 있을경우 if (userPostedFile.ContentLength > 0) { string sourceDir = DirUtil.GetUploadDir("DIR_RECRUITMENT_USER"); string newFile = CStringUtil.GetNewFileName(userPostedFile.FileName); if (newFile.Contains(@"\")) { string[] arr_newfile = newFile.Split(new char[] { '\\' }); newFile = arr_newfile[arr_newfile.Length - 1]; } string saveFileName = sourceDir + newFile; // 물리파일 전체 경로 string physicalPath = CConst.DIR_ROOT_IMAGE_PATH + saveFileName; // 디렉토리 존재 유무 검사 후 디렉토리 생성 DirUtil.MakeDir(CConst.DIR_ROOT_IMAGE_PATH + sourceDir); // 파일 저장 userPostedFile.SaveAs(physicalPath); string fileUrl = saveFileName; if (CStringUtil.IsNullOrEmpty(fileUrl)) { // 실패한 경우에 파일 명 공백 saveFileName = ""; } else { saveFileName = fileUrl; } //CXmlMaker xmlMaker = new CXmlMaker(); //xmlMaker.StartXml(); //xmlMaker.Tag("file_path", saveFileName); Response.Write(saveFileName); Response.Flush(); Response.End(); } } } }
public static async Task ReadQrAsync(this TelegramService telegramService) { try { var chatId = telegramService.ReducedChatId; if (telegramService.ReplyToMessage == null) { await telegramService.SendTextMessageAsync( sendText : "Silakan balas pesan untuk membaca QR Code", scheduleDeleteAt : DateTime.UtcNow.AddMinutes(1), includeSenderMessage : true, preventDuplicateSend : true ); return; } await telegramService.SendTextMessageAsync("Sedang mengambil berkas"); var localFile = await telegramService.DownloadFileAsync("qr"); await telegramService.EditMessageTextAsync("Sedang membaca QR Code"); var qrReadResults = await localFile.ReadQrCodeAsync(); var symbol = qrReadResults.FirstOrDefault()?.Symbol.FirstOrDefault(); var result = symbol?.Data ?? "Tidak terdeteksi adanya QR Code"; await telegramService.EditMessageTextAsync( sendText : result, scheduleDeleteAt : DateTime.UtcNow.AddMinutes(10), includeSenderMessage : true ); DirUtil.CleanCacheFiles( path => path.Contains(chatId.ToString()) && path.Contains("qr") ); } catch (FlurlHttpException httpException) { await telegramService.EditMessageTextAsync( "Terjadi kesalahan ketika membaca QR." + "\nErrorCode: " + httpException.StatusCode ); } catch (Exception exception) { Log.Error(exception, "Error while read qr"); } }
void eExportInfoDump(object sender, EventArgs args) { if (Client.tvRes.SelectedNode.Index != 0) { MessageBox.Show(res.err_pe_load, "first"); return; } string name = ((Client.tvRes.SelectedNode).Tag as LibLoader2).LibraryPath; if (name == null) { throw new ArgumentException(string.Format(res.err_arg_filter, (Client.tvRes.SelectedNode).Tag)); } MessageBox.Show(name); string pathname = Path.GetFileNameWithoutExtension(name); string basepath = Cor3.FileUtil.GetDir(string.Format(bp, pathname)); if (basepath == string.Empty) { return; } string newdir = DirUtil.CreateIfNoExist(Path.Combine(basepath, pathname)); string stroutput = string.Empty; res_info wry = Resources[name].ToResInfo(); foreach (res_category ri in wry.table_data) { string tpath = DirUtil.CreateIfNoExist(Path.Combine(newdir, string.Format("{0}", ri.table_id))); foreach (res_table rt in ri.table_data) { thought?t = new thought(Resources[name], ri.table_id, rt._n, rt.Lang); Application.DoEvents(); byte[] bits = LoadBinary(t); if (t.GetValueOrDefault().table.type == "BITMAP") { BITMAPINFOHEADER bih = BITMAPINFOHEADER.CreateMemory(bits); string imagename = ckpath(tpath, ckname(t, bih)); // convert the dir/name SaveImage(imagename, t, bih); rt.ext_info = imagename; } else { SaveImage(Path.Combine(tpath, rt.name), bits); } t = null; stroutput += string.Format("{0}:{1}\n", rt._n, rt._t); } } if (Resources.ContainsKey(name)) { Resources[name].SaveXml(wry, newdir, pathname); } Client.richTextBox1.Text = stroutput; }
public void Execute() { Debug.LogError(""); foreach (var entity in _group.GetEntities()) { var move = entity.move; var dirVec = DirUtil.GetDirLVec(entity.dir.value); var offset = (move.moveSpd * new LFloat(null, 16)) * dirVec; //entity.pos.value = entity.pos.value + offset; } }
private void CopyFile(List <string> listSrcPath, List <string> listDestPath) { if (listSrcPath.Count() != listDestPath.Count()) { throw new Exception("抱歉!源路径和目标路径数不相等!无法一一复制!"); } for (int i = 0; i < listSrcPath.Count(); i++) { //请保证来源路径和目标路径是一一对应的 DirUtil.CreateDir(listDestPath[i]); FileUtils.CopyFile(listSrcPath[i], listDestPath[i]); //有时会出现错误:指定的路径或文件名太长,或者两者都太长。完全限定文件名必须少于 260 个字符,并且目录名必须少于 248 个字符 } }
private void CheckDestDir() { string strDestBaseDir = txtDestDir.Text; if (Directory.Exists(strDestBaseDir)) { if (DialogResult.OK == MessageBox.Show("已存在目录" + "是否先连子目录也删除?\n" + strDestBaseDir, "目录已存在!是否先连子目录也删除?", MessageBoxButtons.OKCancel)) { DirUtil.DeleteDirRecursive(strDestBaseDir); } } }
public async Task <Realm> GetMongoRealmInstance() { var realmPath = DirUtil.PathCombine(true, "Storage/Data/Realm.realm").EnsureDirectory(); var realmInstance = await Realm.GetInstanceAsync( new RealmConfiguration(realmPath) { ShouldDeleteIfMigrationNeeded = true } ); return(realmInstance); }
private void Init() { NonNullPar(nameof(Config.DestinationSubDir), Config.DestinationSubDir); NonNullPar(nameof(Config.Architecture), Config.Architecture); NonNullPar(nameof(Config.OS), Config.OS); NonNullPar(nameof(Config.ReleaseType), Config.ReleaseType); Config.DestinationSubDir = PathBuilder.BuildPath(nameof(Config.DestinationSubDir), Config.DestinationSubDir, BaseConfig.DestinationDir); Log.Info($"Set {nameof(Config.DestinationSubDir)}='{Config.DestinationSubDir}'"); DirUtil.EnsureCreatedAndClean(Config.DestinationSubDir); }
public bool Run(Configuration config, VariantConfig variantConfig) { Log.Info($"Extracting Zip starting for '{variantConfig.Name}'"); DirUtil.EnsureCreatedAndClean(variantConfig.OutputFilesDirFolder); ZipFile.ExtractToDirectory(variantConfig.DecompiledFile, variantConfig.OutputFilesDirFolder); Log.Info("Extracting Zip finished"); return(true); }
public void ConfigSaveDefault() { if (File.Exists(configFile) == false) { if (!DirUtil.Exists(Application.dataPath + "/../UserData/_scripts/config/")) { DirUtil.Create(Application.dataPath + "/../UserData/_scripts/config/"); } this.ConfigRead(this.config); this.ConfigSave(); } }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage addbom <path> <*.cpp;*.c;*.h>"); } else { //Console.WriteLine("UTF8:\r\n{0}", BitConverter.ToString(utf8)); //Console.WriteLine("GBK:\r\n{0}", BitConverter.ToString(gbk)); //Console.WriteLine("UCS2:\r\n{0}", BitConverter.ToString(ucs2)); var pat = args[1].Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); var ff = DirUtil.GetFiles(args[0], pat, SearchOption.AllDirectories).OrderBy(L => L).ToArray(); Console.WriteLine($"Total Files: {ff.Length}"); var fix = new utf8util.utf8fix(); int ln = 0; var gbkEcs = Encoding.GetEncoding("GBK"); bool changed; foreach (var f in ff) { //UTF8的部分 这个可以修回来 //GBK的部分,要用python //或者 python 按行转为UTF8 //这个纠 UTF8的 //var lo = new List<string>(); ln = 0; var oo = System.IO.File.ReadAllLines(f); int i; string theLn; changed = false; for (i = 0; i < oo.Length; ++i) { theLn = oo[i].Trim().Replace("\t", "").Replace(" ", ""); if (theLn.Length == 0 && i > 1 && oo[i - 1].EndsWith("\\")) { oo[i - 1] = oo[i - 1].TrimEnd('\\'); if (!changed) { changed = true; } } } if (changed) { Console.WriteLine($"{f} changed"); System.IO.File.WriteAllLines(f, oo, Encoding.UTF8); } } Console.WriteLine("Done"); } }
public static bool HasColliderWithBorder(EDir dir, LVector2 fTargetHead, LFloat size) { LVector2 borderDir = DirUtil.GetBorderDir(dir).ToLVector2(); var fBorder1 = fTargetHead + borderDir * size; var fBorder2 = fTargetHead - borderDir * size; var isColHead = HasCollider(fTargetHead); var isColBorder1 = HasCollider(fBorder1); var isColBorder2 = HasCollider(fBorder2); return(isColHead || isColBorder1 || isColBorder2); }
public void Execute() { foreach (var entity in _AIGroup.GetEntities()) { var aiInfo = entity.aI; aiInfo.timer += _gameStateService.DeltaTime; if (aiInfo.timer < aiInfo.updateInterval) { continue; } aiInfo.timer = LFloat.zero; LVector2Int dir = LVector2Int.zero; var curPos = entity.pos.value; var headPos = TankUtil.GetHeadPos(entity.pos.value, entity.dir.value); var isReachTheEnd = _gameCollisionService.HasColliderWithBorder(entity.dir.value, headPos); if (isReachTheEnd) { List <int> allWalkableDir = new List <int>(); for (int i = 0; i < (int)(EDir.EnumCount); i++) { var vec = DirUtil.GetDirLVec((EDir)i) * TankUtil.TANK_HALF_LEN; var pos = curPos + vec; if (!_gameCollisionService.HasCollider(pos)) { allWalkableDir.Add(i); } } var count = allWalkableDir.Count; if (count > 0) { entity.dir.value = (EDir)(allWalkableDir[_randomService.Range(0, count)]); entity.move.isChangedDir = true; } } //Fire skill var isNeedFire = _randomService.value < aiInfo.fireRate; if (isNeedFire) { if (entity.skill.cdTimer <= LFloat.zero) { entity.skill.cdTimer = entity.skill.cd; //Fire _gameUnitService.CreateBullet(entity.pos.value, entity.dir.value, (ushort)entity.skill.bulletId, entity); } } } }
public static List <Vector3Int> DebugQueryCollider(EDir dir, LVector2 fTargetHead, LFloat size) { var ret = new List <Vector3Int>(); LVector2 borderDir = DirUtil.GetBorderDir(dir).ToLVector2(); var fBorder1 = fTargetHead + borderDir * size; var fBorder2 = fTargetHead - borderDir * size; var isColHead = HasCollider(fTargetHead); var isColBorder1 = HasCollider(fBorder1); var isColBorder2 = HasCollider(fBorder2); ret.Add(new Vector3Int(fTargetHead.Floor().x, fTargetHead.Floor().y, isColHead ? 1 : 0)); ret.Add(new Vector3Int(fBorder1.Floor().x, fBorder1.Floor().y, isColBorder1 ? 1 : 0)); ret.Add(new Vector3Int(fBorder2.Floor().x, fBorder2.Floor().y, isColBorder2 ? 1 : 0)); return(ret); }
public static void LoadConfig() { if (!File.Exists(jsonPath)) { DirUtil.CreateDirectoryIfNotExist(ConfigFolder); Instance = new UserConfig(); Instance.LoadDefaults(); string jsonString = JsonConvert.SerializeObject(Instance, Formatting.Indented); DirUtil.WriteTextToFile(jsonPath, jsonString); } Instance = new UserConfig(); JsonConvert.PopulateObject(DirUtil.ReadTextFile(jsonPath), Instance); }
public static async Task <string> ScanMediaAsync(this TelegramService telegramService) { var chatId = telegramService.ChatId; try { var op = Operation.Begin("Scanning Media from ChatId: {ChatId}", chatId); var message = telegramService.MessageOrEdited; if (message.Document == null && message.Photo == null) { return(string.Empty); } var qrDecoder = telegramService.GetRequiredService <QRDecoder>(); var qrFile = await telegramService.DownloadFileAsync("qr-reader"); var image = await Image.LoadAsync(qrFile); var qrResult = qrDecoder.ImageDecoder(image); var data = QRDecoder.ByteArrayToString(qrResult.FirstOrDefault()); DirUtil.CleanCacheFiles( s => s.Contains(chatId.ReduceChatId().ToString()) && s.Contains("qr-reader") ); op.Complete(); return(data); } catch (Exception exception) { Log.Error( exception, "Error occured when Scan Media at ChatId {ChatId}", chatId ); return(string.Empty); } }
/// <summary> /// Create prefabs with current selection /// </summary public static GameObject CreatePrefabFromActiveGO(string path) { var go = Selection.activeGameObject; // Check for folder var localPath = path; if (!DirUtil.CheckForProjectPath(localPath)) { DirUtil.CreateFolderTree(localPath); } // Fill array of prefabs var prefab = PrefabUtility.CreatePrefab(localPath + go.name + ".prefab", go); return(prefab); }
public static void PackIFS(string inputDir, string outIFSPath) { InitInner(); if (!Directory.Exists(inputDir)) { throw new ArgumentException($"'{inputDir}' is not a directory!", nameof(inputDir)); } if (PathUtil.Exists(outIFSPath)) { PathUtil.RemovePath(outIFSPath); } DirUtil.TryCreateParentDir(outIFSPath); Logger.VerboseLog($"Packing ifs '{outIFSPath}' from directory '{inputDir}'..."); s_nifs.Execute($"create \"{inputDir}\" \"{outIFSPath}\""); }
public void ApplyExplodeCross(GameEntity entity) { var dist = entity.bomb.damageRange; var rawPos = entity.pos.value.Floor(); _tempBombLst.Add(entity); explodedPoss.Add(rawPos); entity.isDestroyed = true; //Check 4 dir for (int i = 0; i < (int)EDir.EnumCount; i++) { var dirVec = DirUtil.GetDirVec((EDir)i); ApplyExplodeLine(entity, rawPos, dirVec); } //check the centerPos ApplyExplodePoint(entity, rawPos); }
private void button1_Click(object sender, EventArgs e) { //假如输入的是目录列表,那么先转换为文件列表,然后如上复制文件即可实现复制目录以及子目录 List <string> listSrcPath = new List <string>(); foreach (string str in richCopyFiles.Text.GetSplitLineWithoutEmpty()) { foreach (FileInfo fileInfo in DirUtil.getAllFile(str)) { listSrcPath.Add(fileInfo.FullName); } } richCopyFiles.Text = ""; foreach (string str in listSrcPath) { richCopyFiles.Text += $"{str}\n"; } }
private void CopyFile(List <string> listSrcPath, string strDestBaseDir, ref string msg) {//将这些路径下的文件都复制到目录strDestBaseDir下 List <string> listDestPath = new List <string>(); foreach (string srcPath in listSrcPath) { if (DirUtil.IsFileDirectory(srcPath)) { //listPath.Add(srcPath); listDestPath.Add(getDestPath(strDestBaseDir, srcPath)); } else { msg += $"源文件路径:{srcPath}不存在!\n"; } } CopyFile(listSrcPath, listDestPath); }
/// <summary> /// 공통 파일 삭제 /// </summary> /// <param name="tb"></param> /// <param name="col"></param> /// <param name="key"></param> /// <returns></returns> protected bool DeleteFile(int procIndex, string param, string path) { bool result = false; try { ExecuteQuery(procIndex, param); // 물리 파일 삭제 DirUtil.DeleteFile(CConst.DIR_ROOT_IMAGE_PATH + path); result = true; } catch (Exception e) { CLog.debug(logger, "PageBase.DeleteFile(" + procIndex + "," + param + "," + path + ") : " + e.Message); } return(result); }
public ZipReturn ZipFileCreate(string newFilename) { if (ZipOpen != ZipOpenType.Closed) { return(ZipReturn.ZipFileAlreadyOpen); } DirUtil.CreateDirForFile(newFilename); _fileInfo = new FileInfo(newFilename); int errorCode = FileStream.OpenFileWrite(newFilename, out _inStream); if (errorCode != 0) { ZipFileClose(); return(ZipReturn.ZipErrorOpeningFile); } ZipOpen = ZipOpenType.OpenWrite; return(ZipReturn.ZipGood); }
void eDirectoryItemHover(object sender, EventArgs args) { if (DoPop(sender)) { return; } string path = (sender as ToolStripMenuItem).Tag as string; string[] directories = DirUtil.GetDirList(path); if (directories == null) { return; } (sender as ToolStripMenuItem).ShortcutKeyDisplayString = "»"; (sender as ToolStripMenuItem).ShowShortcutKeys = true; foreach (string pth in directories) { (sender as ToolStripMenuItem).DropDownItems.Add(MakeItem(pth)); } DoPop(sender); }
private void RunDeobfuscation(Configuration config, VariantConfig variant) { Log.Info($"Deobfusctor starting for '{variant.Name}'"); DirUtil.EnsureCreatedAndClean(Directory.GetParent(variant.DeObfuscatedFile).ToString()); var formattedBaseCommand = config.BaseDeobfuscatorCommand .Replace("{Deobfuscator}", config.Deobfuscator) .Replace("{SrcJar}", variant.SrcJar) .Replace("{PatchFile}", variant.PatchFile) .Replace("{DeObfuscatedFile}", variant.DeObfuscatedFile); var command = $"{formattedBaseCommand}{(variant.ExcludedComponents.Count > 0 ? $" -ec {string.Join(",",variant.ExcludedComponents)}" : "")}"; if (!ProcessUtil.RunProcess(config.JavaExePath, command, config.DeobfuscatorTimeout)) { throw new TaskCanceledException(); } Log.Info("Deobfusctor finished"); }
public void Launch(Direction direction) { this.speed = riseSpeed; this.direction = direction; this.startPos = transform.position; if (direction == Direction.Left || direction == Direction.Right) { travelDist = horizontalTravelDist; } else { travelDist = verticalTravelDist; } movDir = DirUtil.DirectionToVec(direction); int soundToPlay = Random.Range(1, 5); AudioController.Instance.PlaySound("swish_" + soundToPlay); }
/// <summary> /// Creates an asset bundle for an specific platform and return its manifest /// </summary> /// <param name="prefab">Prefab to create the asset from</param> /// <param name="name">Name of the asset bundle</param> /// <param name="path">Temporal path</param> /// <returns>The asset bundle manifest</returns> public static AssetBundleManifest CreateAssetBundle(GameObject prefab, string name, string path, BuildTarget platform) { var assetName = AssetDatabase.GetAssetPath(prefab); // Check for folder var localPath = path; if (!DirUtil.CheckForProjectPath(localPath)) { DirUtil.CreateFolderTree(localPath); } // Create bundle AssetBundleBuild[] buildMap = new AssetBundleBuild[1]; buildMap[0] = new AssetBundleBuild(); buildMap[0].assetBundleName = name; buildMap[0].assetNames = new string[] { assetName }; var manifest = BuildPipeline.BuildAssetBundles(path, buildMap, BuildAssetBundleOptions.ChunkBasedCompression, platform); return(manifest); }
protected string UploadFile(FileUpload upload, string dirKey) { string saveFileName = ""; if (upload.HasFile) { string sourceDir = DirUtil.GetUploadDir(dirKey); string newFile = GetNewFileName(upload.FileName); saveFileName = sourceDir + newFile.Replace(" ", ""); // 공백은 제거 // 물리파일 전체 경로 string physicalPath = CConst.DIR_ROOT_IMAGE_PATH + saveFileName; // 디렉토리 존재 유무 검사 후 디렉토리 생성 DirUtil.MakeDir(CConst.DIR_ROOT_IMAGE_PATH + sourceDir); // 파일 저장 upload.SaveAs(physicalPath); string fileUrl = saveFileName; //string fileUrl = DirUtil.CopyRemoteServer(sourceDir, newFile); if (CStringUtil.IsNullOrEmpty(fileUrl)) { // 실패한 경우에 파일 명 공백 saveFileName = ""; } else { saveFileName = fileUrl; } } else { System.Diagnostics.Debug.WriteLine("upload.HasFile:" + upload.HasFile); } return(saveFileName); }
//-///////////////////////////////////////////////////////////////////// public List <ToolStripItem> GetDirectoryList(string path) { DirectoryInfo di = new DirectoryInfo(path); if (di == null) { return(null); } if (!di.Exists) { return(null); } List <ToolStripItem> items = new List <ToolStripItem>(); if (di.Root.FullName != di.FullName) { items.Add(ParentItemNavigation); } else { items.AddRange( new ToolStripItem[] { DesktopItem, ActivePathBrowseItem, DriveItems, ControlUtil.TSItem() } ); } string[] directories = DirUtil.GetDirList(path); if (directories != null) { foreach (string dn in directories) { items.Add(MakeItem(dn)); } } return(items); }
public static void ModifyMacro(string nssUnityProj, BuildMode buildMode, PackageType packageType, BuildOption buildOption) { Logger.Log("开始修改客户端宏文件..."); var mcsPath = Path.Combine(nssUnityProj, "Assets/mcs.rsp"); if (!File.Exists(mcsPath)) { throw new ArgumentException($"Can't find mcs.rsp in '{nssUnityProj}'!", nssUnityProj); } MCS mcs = new MCS(mcsPath); mcs.ModifyItemByBuildMode(buildMode); if (packageType == PackageType.Experience) { mcs.TryAddItem("-define:NSS_EXPERIENCE"); } if (buildOption == BuildOption.AI) { mcs.TryAddItem("-define:AVATAR_AI_ENABLE"); } mcs.Serialize(mcsPath); Logger.Log("修改后的宏文件:"); Logger.Log(File.ReadAllText(mcsPath)); var sha1FilePath = SpaceUtil.GetPathInPersistent("MCSSha1"); var newSha1 = FileUtil.ComputeSHA1(mcsPath); if (!File.Exists(sha1FilePath) || File.ReadAllText(sha1FilePath) != newSha1) {// 宏变了,要删除dll,强制重编 Logger.Log("宏变了,删除旧的DLL..."); DirUtil.ClearDir(Path.Combine(nssUnityProj, "Library/ScriptAssemblies")); } File.WriteAllText(sha1FilePath, newSha1); }