//──────────────────────────────────────── /// <summary> /// パスを設定します。 /// </summary> /// <param name="folderRel_New">フォルダーのパス。</param> /// <param name="fileBoth_Newhumaninput">ファイルの相対パス、または絶対パス。</param> public static Expr_Filepath Init2( string folderRel_New, string fileBoth_Newhumaninput, string confName, Conf_String cParent_OrNull, Log_Reports log_Reports ) { // ツール設定ファイルへのパスは固定とします。 Expr_Filepath eFileRel = null; { Conf_Filepath cFileRel = new Conf_FilepathImpl(confName, cParent_OrNull); // #コンフィグ作成 cFileRel.Init1( folderRel_New, fileBoth_Newhumaninput, log_Reports); if (log_Reports.Successful) { eFileRel = new Expr_FilepathImpl(cFileRel); } } return(eFileRel); }
//──────────────────────────────────────── /// <summary> /// ファイル名の頭と末尾に文字列を付けることができます。 /// </summary> /// <param name="prefix">ファイル名の頭に付ける文字列。</param> /// <param name="suffix">ファイル名の末尾に付ける文字列。</param> public Expr_Filepath Rename_Append(string prefix, string suffix, Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Syntax.Name_Library, this, "Rename_Append", log_Reports); Expr_Filepath result; string absolute = this.Lv4Execute_OnImplement(Syntax.EnumHitcount.Unconstraint, log_Reports); if ("" == absolute) { result = null; goto gt_Error_Empty; } string directory = Path.GetDirectoryName(absolute); string filename = Path.GetFileNameWithoutExtension(absolute); string extension = Path.GetExtension(absolute);//拡張子の「.」を含む。 absolute = Path.Combine(directory, prefix + filename + suffix + extension); result = Expr_FilepathImpl.Init2( "", absolute, "<rename>", null, log_Reports ); goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_Empty: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー931!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("ファイルパスが空文字列でした。"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); return(result); }
//──────────────────────────────────────── /// <summary> /// 属性。 /// </summary> /// <param name="out_E_Result">検索結果。</param> /// <param name="name"></param> /// <param name="bRequired"></param> /// <param name="hits"></param> /// <param name="log_Reports"></param> /// <returns>検索結果が1件以上あれば真。</returns> public bool TrySelectAttribute_ExpressionFilepath( out Expr_Filepath eResult_Out, string name, EnumHitcount hits, Log_Reports log_Reports ) { // 使いません。 eResult_Out = Expr_FilepathImpl.Init2( "", "", name, this.Conf, log_Reports ); return(false); }
//──────────────────────────────────────── /// <summary> /// このデータは、ファイルパス型だ、と想定して、ファイルパスを取得します。 /// </summary> /// <returns></returns> public static Expr_Filepath Execute4_OnExpressionString_AsFilepath_Impl( Expr_String eCaller, EnumHitcount request, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Syntax.Name_Library, eCaller, "Execute4_OnExpressionString_AsFilepath_Impl", log_Reports); // // // // Expr_Filepath reulst_eRel; // // ファイルパス。 string sFpath = eCaller.Lv5_Implement(log_Reports); { reulst_eRel = Expr_FilepathImpl.Init2( "", sFpath, "ファイルパス出典未指定L01_1", eCaller.Conf, log_Reports ); if (!log_Reports.Successful) { // 既エラー。 reulst_eRel = null; goto gt_EndMethod; } } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(reulst_eRel); }
/// <summary> /// /// </summary> /// <param name="e_Result">検索結果。</param> /// <param name="name_Attribute"></param> /// <param name="bRequired"></param> /// <param name="hits"></param> /// <param name="log_Reports"></param> /// <returns>検索結果が1件以上あれば真。</returns> public bool TrySelect_ExpressionFilepath( out Expr_Filepath out_eFliepath, string name_Attribute, EnumHitcount hits, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Syntax.Name_Library, this, "TrySelect_ExpressionFilepath", log_Reports); string value; bool isResult = this.TrySelect2(out value, name_Attribute, hits, log_Reports); out_eFliepath = Expr_FilepathImpl.Init2( "", value, log_Method.Fullname, null, log_Reports ); //switch (hits) //{ // case EnumHitcount.One: // { // if (!isResult) // { // //エラー // goto gt_Error_NotFoundOne; // } // } // break; // //todo:他の制約も。 //} goto gt_EndMethod; // // #region 異常系 ////──────────────────────────────────────── //gt_Error_NotFoundOne: // if (log_Reports.CanCreateReport) // { // Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); // r.SetTitle("▲エラー281!", log_Method); // StringBuilder s = new StringBuilder(); // s.Append("必ず、1件を取得する指定でしたが、1件も存在しませんでした。キー=["); // s.Append(name_Attribute); // s.Append("]"); // // ヒント // r.Message = s.ToString(); // log_Reports.EndCreateReport(); // } // goto gt_EndMethod; ////──────────────────────────────────────── // #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); return(isResult); }