public void Export() { try { String exportPath = ExportPath; if (File.Exists(exportPath)) { Log.Warning($"[{TypeName}] Export was skipped bacause a file already exists: [{exportPath}]."); return; } Log.Message($"[{TypeName}] Exporting..."); TxtEntry[] abilities = PrepareEntries(); FileCommander.PrepareFileDirectory(exportPath); TxtWriter.WriteStrings(exportPath, abilities); Log.Message($"[{TypeName}] Exporting completed successfully."); } catch (Exception ex) { Log.Error(ex, $"[{TypeName}] Failed to export resource."); } }
public void DoGetTest() { string filePath = RootPath + "/TestDirectories/Directory2/Hello.txt"; string expectedData = "29 A Hello World! program in C#."; string data = FileCommander.DoGetCommand(filePath); Assert.AreEqual(expectedData, data); }
public void DoListTest() { string path = RootPath + "/TestDirectories/Directory1"; string expectedData = "3 TestDirectory true TestFile1.txt false TestFile2.txt false "; string data = FileCommander.DoListCommand(path); Assert.AreEqual(expectedData, data); }
private static void ExportSoundSafe(String akbOutputPath, TextAsset textAsset) { try { String oggOutputPath = akbOutputPath + ".ogg"; String fileName; String directoryPath; String alternativePath; if (AudioResources.TryAppendDisplayName(akbOutputPath, out directoryPath, out fileName, out alternativePath)) { alternativePath += ".ogg"; if (File.Exists(alternativePath)) { Log.Warning("[AudioResourceExporter] Export was skipped bacause a file already exists: [{0}].", alternativePath); return; } if (File.Exists(oggOutputPath)) { Log.Message("[AudioResourceExporter] The file [{0}] will be renamed to [{1}].", oggOutputPath, alternativePath); File.Move(oggOutputPath, alternativePath); Log.Warning("[AudioResourceExporter] Export was skipped bacause a file already exists: [{0}].", alternativePath); return; } oggOutputPath = alternativePath; } else if (File.Exists(akbOutputPath)) { Log.Warning("[AudioResourceExporter] Export was skipped bacause a file already exists: [{0}].", akbOutputPath); return; } else { oggOutputPath = akbOutputPath + ".ogg"; } FileCommander.PrepareFileDirectory(akbOutputPath); using (Stream akb = File.Create(akbOutputPath)) using (Stream ogg = File.Create(oggOutputPath)) { akb.Write(textAsset.bytes, 0, textAsset.bytes.Length); ogg.Write(textAsset.bytes, 304, textAsset.bytes.Length - 304); } File.SetLastWriteTimeUtc(akbOutputPath, File.GetLastWriteTimeUtc(oggOutputPath)); } catch (Exception ex) { Log.Error(ex, "[AudioResourceExporter] Failed to export sound [{0}] to the [{1}].", textAsset.name, akbOutputPath); } }
public static void ToDirectory(GameFont extraFont, string dirPath) { string xmlPath = FileCommander.EnsureDirectoryExists(dirPath, "Characters.xml"); XmlElement characters = XmlHelper.CreateDocument("Characters"); foreach (byte width in extraFont.CharactersWidths) { characters.CreateChildElement("Character").SetByte("Width", width); } characters.GetOwnerDocument().Save(xmlPath); GameImageWriter.ToDirectory(extraFont.CharactersImage, dirPath); }
public bool EndWrite() { FileCommander.EnsureDirectoryExists(_xmlPath); _root.GetOwnerDocument().Save(_xmlPath); return(true); }
public bool BeginWrite() { FileCommander.EnsureDirectoryExists(_xmlPath); _root = File.Exists(_xmlPath) ? XmlHelper.LoadDocument(_xmlPath) : XmlHelper.CreateDocument("Location"); return(true); }