private static void Convert(string From) { int last = From.LastIndexOfAny(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); int dot = From.LastIndexOf('.'); string To = From; FType FileType = WADfile.GetType(File.ReadAllBytes(From)); //check if file has extension, if so, cut off if (dot > last) { To = From.Substring(0, dot); } if (FileType == FType.MUS) { To += ".MID"; } else if (FileType == FType.RAWAUDIO) { To += ".WAV"; } else { To += "." + FileType.ToString(); } //very simple check, if the destination is the same as the source, ignoring character case if (File.Exists(To) && WADfile.getHash(File.ReadAllBytes(From)) == WADfile.getHash(File.ReadAllBytes(To))) { Log(ConsoleColor.Yellow, "File would be identical after generating destination name. Not converting"); } else { Convert(From, To); } }
private static void Convert(string FromFile) { Log(Verbosity.Debug, "Converting {0} to auto generated name", FromFile); int last = FromFile.LastIndexOfAny(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); int dot = FromFile.LastIndexOf('.'); string To = FromFile; FType FileType = WADfile.GetDataType(File.ReadAllBytes(FromFile)); //check if file has extension, if so, cut off if (dot > last) { To = FromFile.Substring(0, dot); } if (FileType == FType.MUS) { To += ".MID"; } else if (FileType == FType.RAWAUDIO) { To += ".WAV"; } else { To += "." + FileType.ToString(); } //very simple check, if the destination is the same as the source, ignoring character case if (File.Exists(To) && WADfile.getHash(File.ReadAllBytes(FromFile)) == WADfile.getHash(File.ReadAllBytes(To))) { Log(Verbosity.Warn, "File would be identical after generating destination name. Not converting"); } else { Log(Verbosity.Debug, "Auto-Generated File Name: {0}", To); Convert(FromFile, To); } }