//──────────────────────────────────────── /// <summary> /// 相対パスが設定されていた場合、その相対元となるディレクトリーへのパスです。 /// そうでない場合は、System.Windows.Forms.StartupPath を入れてください。 /// </summary> /// <param name="newDirectoryPath"></param> public void SetDirectory_Base( string sFolderpath_New, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Syntax.Name_Library, this, "SetSDirectory_Base", log_Reports); // ダミー・フラグ。使いません。 bool bDammyFlagCheckPathTooLong = false; if (this.Conf is Conf_Filepath) { Conf_Filepath cf_Fpath = ((Conf_Filepath)this.Conf); // チェック。絶対パスにすることができればOK。 Util_Filepath.ToAbsolute( sFolderpath_New, cf_Fpath.GetHumaninput(), ref bDammyFlagCheckPathTooLong, false, //ファイル名の長さが上限超過ならエラー log_Reports, //out sErrorMsg, this.Conf ); if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } cf_Fpath.SetDirectory_Base(sFolderpath_New); } else { // エラー if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー903!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append(Environment.NewLine); s.Append("#GetSAbsoluteFilePath:型が違います。[" + this.Conf.GetType().Name + "]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } } // // // // gt_EndMethod: log_Method.EndMethod(log_Reports); return; }
//──────────────────────────────────────── public static string ToAbsolute( Conf_Filepath cFileRel, ref bool isTooLong, bool isSafe_TooLong, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Syntax.Name_Library, "Util_Filepath", "ToAbsolute①", log_Reports); string sResult; if (log_Reports.Successful) { sResult = Util_Filepath.ToAbsolute( "", cFileRel.GetHumaninput(), ref isTooLong, isSafe_TooLong, log_Reports,//out sErrorMsg, cFileRel ); } else { sResult = ""; } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(sResult); }
//──────────────────────────────────────── /// <summary> /// コンストラクター。 /// </summary> /// <param name="s_Fpath"></param> public Expr_FilepathImpl(Conf_Filepath fpath_Conf) : base(null, fpath_Conf) { }
//──────────────────────────────────────── /// <summary> /// 絶対パスを取得します。 /// /// 未設定の場合は、空文字列を返します。 /// /// ・ファイルパスとして利用できない文字や、予約語が含まれていると例外を投げます。 /// ・絶対パスの文字列の長さが、ファイルシステムで使える制限を越えると例外を投げます。 /// /// 設定されたパスが相対パスだった場合に、ベース・パスが設定されていなければ、 /// 起動「.exe」のあったパスが頭に付く。 /// </summary> /// <returns></returns> public override string Lv4Execute_OnImplement( EnumHitcount request, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Syntax.Name_Library, this, "Execute4_OnExpressionString", log_Reports); // // // 絶対パスにして返します。 string sFpath; if (this.Conf is Conf_Filepath) { Conf_Filepath cf_Fpath = (Conf_Filepath)this.Conf; bool bCheckPathTooLong = false; if (log_Reports.Successful) { sFpath = Util_Filepath.ToAbsolute( this.Directory_Base, cf_Fpath.GetHumaninput(), //this.SHumanInput相当 ref bCheckPathTooLong, //ファイル名の長さチェックは、もう済んでいるものとして、行いません。 false, //ファイル名の長さが上限超過ならエラー log_Reports, //out sErrorMsg, this.Conf ); } else { sFpath = ""; } } else { // エラー。 sFpath = ""; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー901!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append(Environment.NewLine); s.Append("#GetSAbsoluteFilePath:型が違います。[" + this.Conf.GetType().Name + "]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(sFpath); }