File indexing completed on 2025-05-11 08:24:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 using System;
0041 using System.Collections.Generic;
0042 using System.IO;
0043 using System.Diagnostics;
0044 using System.Threading;
0045 using System.Text;
0046
0047 namespace Create_Files
0048 {
0049 public static class Create_Files
0050 {
0051 // Strings for file names and file contents
0052 public static string[] Strings = new string[] {
0053 "this is a long filename",
0054 "đây là một tên tập tin dài",
0055 "Bu uzun bir dosya adı",
0056 "هذا هو اسم ملف طويل",
0057 "αυτό είναι ένα μεγάλο όνομα αρχείου",
0058 "это длинное имя",
0059 "гэта доўгае імя",
0060 "това е дълго име на файла",
0061 "这是一个长文件名",
0062 "মেৰিকা মহাদেশ, উত্তৰ আমেৰিকা আৰু দক্ষিণ আমেৰিকা মহাদেশক লৈ গঠিত এক",
0063 "آمریکا قاره یکته قارهٰ زمینˇ قارهٰنˇ مئن ایسسه کی زمینˇ هنهشر (مساحت)ˇ جی ۳۸٪ و زمینˇ خوشکیئنˇ جی ۴۲۸٪ ای قاره شی ایسسه",
0064 "Manâhestôtse 910,720,588 (July 2008 est.)",
0065 "Elle s'étend depuis l'océan Arctique au nord jusqu'au cap Horn dans le passage de Drake au sud, à la confluence des océans",
0066 "ཨ་མེ་རི་ཀ, ཨ་མེ་རི་ཁ, མེ་གླིང་",
0067 "е су земље западне хемисфере или Новог света које се састоје од континената Северна Америка",
0068 "This is a filename with with 255 characters. The following numbers are aligned in that way, that the character 0 is the mentioned one. xx140xxxxxxx150xxxxxxx160xxxxxxx170xxxxxxx180xxxxxxx190xxxxxxx200xxxxxxx210xxxxxxx220xxxxxxx230xxxxxxx240xxxxxxx250xxxxx",
0069 "Bu gezegen Roma mitolojisindeki savaş ilahı Mars'a",
0070 "Amerike su zemlje zapadne hemisfere ili Novog svijeta koje se sastoje od kontinenata Sjeverna Amerika i Južna Amerika sa svim pridruženim otocima i regijama.",
0071 "იანებს ორ კონტინენტს, სამხრეთ და ჩრდილოეთ ამერიკას ახლომდებარე კუნძულებთან ერ",
0072 " Є то єдиный контінент, котрого цїла теріторія лежыть на Западній півкулї тай разом"
0073 };
0074
0075
0076 public static void FormatDrive(string driveLetter)
0077 {
0078 ProcessStartInfo StartInfo = new ProcessStartInfo();
0079 StartInfo.FileName = Environment.SystemDirectory + "\\cmd.exe";
0080 StartInfo.Arguments = "/C \"format " + driveLetter + " /FS:FAT\"";
0081 StartInfo.UseShellExecute = false;
0082 StartInfo.RedirectStandardInput = true;
0083 Process Process = Process.Start(StartInfo);
0084
0085 Process.StandardInput.WriteLine();
0086 Process.StandardInput.WriteLine();
0087 Process.WaitForExit();
0088 }
0089
0090
0091 public static void Main(string[] args)
0092 {
0093
0094 if ((args.Length <= 0) || (args[0].Equals("-h", StringComparison.InvariantCultureIgnoreCase) || args[0].Equals("-help", StringComparison.InvariantCultureIgnoreCase)))
0095 {
0096 Console.WriteLine("create_files.bat <DRIVE>");
0097 Console.WriteLine("Will format DRIVE and create files on the new formated drive.");
0098 }
0099 else
0100 {
0101
0102 Console.WriteLine(args[0] + " will get formated!");
0103 while (true)
0104 {
0105 Console.WriteLine("Press y to continue or press n to abort. [y\\n]");
0106 string Input = Console.ReadLine();
0107 if (Input[0].Equals('y') || Input[0].Equals('Y'))
0108 break;
0109 else if (Input[0].Equals('n') || Input[0].Equals('N'))
0110 return;
0111 }
0112
0113 FormatDrive(args[0]);
0114
0115
0116 for (int i = 0; i < Strings.GetLength(0); i++)
0117 {
0118 File.WriteAllText(Path.Combine(args[0], Strings[i]), Strings[i], Encoding.UTF8);
0119 Console.WriteLine("The file \"" + Strings[i] + "\" created.");
0120 }
0121
0122
0123
0124 string HeaderPath = Path.Combine(args[0], "files.h");
0125 Console.WriteLine("The header \"" + HeaderPath + "\" will write.");
0126 StreamWriter HeaderStream = new StreamWriter(HeaderPath);
0127
0128 HeaderStream.Write("\n" +
0129 "/*\n" +
0130 " * Array with files, that were created in the FAT-filesystem image.bin.\n" +
0131 " *\n" +
0132 " * WARNING: Automatically generated by Create_Files.cs -- do not edit!\n" +
0133 " */\n" +
0134 "\n" +
0135 "#ifndef __FILE_H__\n" +
0136 "#define __FILE_H__\n" +
0137 "\n" +
0138 "#ifdef __cplusplus\n" +
0139 "extern C {\n" +
0140 "#endif\n" +
0141 "\n" +
0142 "static const char *const filenames[] = {\n");
0143 for (int i = 0; i < Strings.GetLength(0); i++)
0144 HeaderStream.WriteLine(" \"" + Strings[i] + ((i == (Strings.GetLength(0) - 1)) ? "\"" : "\","));
0145 string NumberOfFilesStr = Strings.GetLength(0).ToString(System.Globalization.CultureInfo.InvariantCulture);
0146 HeaderStream.Write("};\n" +
0147 "#define FILES_FILENAMES_NUMBER_OF " + NumberOfFilesStr + "\n" +
0148 "\n" +
0149 "#ifdef __cplusplus\n" +
0150 "}\n" +
0151 "#endif\n" +
0152 "\n" +
0153 "#endif /* __FILE_H__ */\n" +
0154 "\n");
0155
0156
0157 HeaderStream.Flush();
0158 HeaderStream.Close();
0159 HeaderStream.Dispose();
0160 }
0161 }
0162 }
0163 }