Exemplo n.º 1
0
        /** セーブ。BOMなし。UTF8。
         *
         *      a_text							: テキスト。
         *      a_full_path_with_extention		: フルバス。拡張子付き。
         *      a_linefeedoption				: 改行コード。
         *
         */
        public static string SaveNoBomUtf8(string a_text, string a_full_path_with_extention, LineFeedOption a_linefeedoption)
        {
            string t_text;

            switch (a_linefeedoption)
            {
            case LineFeedOption.LF:
            {
                t_text = a_text.Replace("\r", "");
            } break;

            case LineFeedOption.CRLF:
            {
                t_text = a_text.Replace("\r", "");
                t_text = t_text.Replace("\n", "\r\n");
            } break;

            case LineFeedOption.None:
            default:
            {
                t_text = a_text;
            } break;
            }

            using (System.IO.StreamWriter t_stream = new System.IO.StreamWriter(a_full_path_with_extention, false, new System.Text.UTF8Encoding(false))){
                t_stream.Write(t_text);
                t_stream.Flush();
                t_stream.Close();
            }

            return(t_text);
        }
Exemplo n.º 2
0
 /** セーブ。
  *
  *      a_text							: テキスト。
  *      a_full_path_with_extention		: フルバス。拡張子付き。
  *      a_encoding						: エンコード。
  *      a_linefeedoption				: 改行コード。
  *      return.result == true			: 成功。
  *
  */
 public static MultiResult <bool, string> TrySave(string a_text, string a_full_path_with_extention, System.Text.Encoding a_encoding, LineFeedOption a_linefeedoption)
 {
                 #pragma warning disable 0168
     try{
         return(new MultiResult <bool, string>(true, Save(a_text, a_full_path_with_extention, a_encoding, a_linefeedoption)));
     }catch (System.IO.IOException t_exception) {
         //IOエラー。
                         #if (DEF_BLUEBACK_ASSETLIB_ASSERT)
         DebugTool.Assert(false, t_exception);
                         #endif
         return(new MultiResult <bool, string>(false, null));
     }catch (System.Exception t_exception) {
         //エラー。
                         #if (DEF_BLUEBACK_ASSETLIB_ASSERT)
         DebugTool.Assert(false, t_exception);
                         #endif
         return(new MultiResult <bool, string>(false, null));
     }
                 #pragma warning restore
 }
Exemplo n.º 3
0
 /** セーブ。BOMなし。UTF8。
  *
  *      a_text							: テキスト。
  *      a_assets_path_with_extention	: 「Assets」からの相対バス。拡張子付き。
  *      a_linefeedoption				: 改行コード。
  *
  */
 public static string SaveNoBomUtf8(string a_text, string a_assets_path_with_extention, LineFeedOption a_linefeedoption)
 {
     return(SaveTextWithFullPath.SaveNoBomUtf8(a_text, AssetLib.GetApplicationDataPath() + '\\' + a_assets_path_with_extention, a_linefeedoption));
 }
Exemplo n.º 4
0
 /** セーブ。
  *
  *      a_text							: テキスト。
  *      a_assets_path_with_extention	: 「Assets」からの相対バス。拡張子付き。
  *      a_encoding						: エンコード。
  *      a_linefeedoption				: 改行コード。
  *
  */
 public static string Save(string a_text, string a_assets_path_with_extention, System.Text.Encoding a_encoding, LineFeedOption a_linefeedoption)
 {
     return(SaveTextWithFullPath.Save(a_text, AssetLib.GetApplicationDataPath() + '\\' + a_assets_path_with_extention, a_encoding, a_linefeedoption));
 }
Exemplo n.º 5
0
 /** テキストコンバート。
  *
  *      a_assets_path					: 「Assets」からの相対パス。
  *      a_directory_pattern				: ディレクトリ名の正規表現パターン。
  *      a_file_pattern					: ファイル名の正規表現パターン。
  *      a_encoding						: エンコード。
  *      a_linefeed_option				: 改行コード。
  *
  */
 public static bool TryConvertAll(string a_assets_path, string a_directory_pattern, string a_file_pattern, System.Text.Encoding a_encoding, LineFeedOption a_linefeed_option)
 {
                 #pragma warning disable 0168
     try{
         return(ConvertAll(a_assets_path, a_directory_pattern, a_file_pattern, a_encoding, a_linefeed_option));
     }catch (System.Exception t_exception) {
         //エラー。
                         #if (DEF_BLUEBACK_ASSETLIB_ASSERT)
         DebugTool.Assert(false, t_exception);
                         #endif
         return(false);
     }
                 #pragma warning restore
 }
Exemplo n.º 6
0
 /** テキストコンバート。
  *
  *      a_assets_path					: 「Assets」からの相対パス。
  *      a_directory_pattern				: ディレクトリ名の正規表現パターン。
  *      a_file_pattern					: ファイル名の正規表現パターン。
  *      a_encoding						: エンコード。
  *      a_linefeed_option				: 改行コード。
  *
  */
 public static bool ConvertAll(string a_assets_path, string a_directory_pattern, string a_file_pattern, System.Text.Encoding a_encoding, LineFeedOption a_linefeed_option)
 {
     System.Collections.Generic.List <string> t_list = FindFileWithAssetsPath.FindAll(a_assets_path, a_directory_pattern, a_file_pattern);
     for (int ii = 0; ii < t_list.Count; ii++)
     {
         string t_path = t_list[ii];
         string t_text = LoadTextWithAssetsPath.Load(t_list[ii]);
         SaveTextWithAssetsPath.Save(t_text, t_path, a_encoding, a_linefeed_option);
     }
     RefreshAssetDatabase.Refresh();
     return(true);
 }