static Library() { Version = string.Empty; Id = string.Empty; Platform = string.Empty; ResolveDotNetAssemblies = true; var text = ImplementationResources.Configuration; var separators = new[] { '\r', '\n' }; var lines = text.Split(separators, StringSplitOptions.RemoveEmptyEntries); Version = Find("Version", lines); using (var stream = new FileStream(typeof(Library).Assembly.Location, FileMode.Open, FileAccess.Read)) { using (var sha1 = SHA1.Create()) { var hash = sha1.ComputeHash(stream); var id = BitConverter.ToString(hash); Id = id.Replace("-", string.Empty); } } Platform = Environment.Is64BitProcess ? "x64" : "x86"; var appData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); LibPath = IOPath.Combine(appData, FdkLibsName, Library.Id, Library.Platform); }
public StatsSyncher(Session par1Session, StatFileWriter par2StatFileWriter, string par3File) { IsBusy = false; Field_27437_b = null; Field_27436_c = null; Field_27427_l = 0; Field_27426_m = 0; UnsentDataFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append("_unsent.dat").ToString()); DataFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append(".dat").ToString()); UnsentOldFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append("_unsent.old").ToString()); OldFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append(".old").ToString()); UnsentTempFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append("_unsent.tmp").ToString()); TempFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append(".tmp").ToString()); if (!par1Session.Username.ToLower().Equals(par1Session.Username)) { Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append("_unsent.dat").ToString(), UnsentDataFile); Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append(".dat").ToString(), DataFile); Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append("_unsent.old").ToString(), UnsentOldFile); Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append(".old").ToString(), OldFile); Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append("_unsent.tmp").ToString(), UnsentTempFile); Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append(".tmp").ToString(), TempFile); } StatFileWriter = par2StatFileWriter; TheSession = par1Session; if (File.Exists(UnsentDataFile)) { par2StatFileWriter.Func_27179_a(Func_27415_a(UnsentDataFile, UnsentTempFile, UnsentOldFile)); } BeginReceiveStats(); }
/// <summary> /// Checks the session lock to prevent save collisions /// </summary> public virtual void CheckSessionLock() { try { string file = IOPath.Combine(SaveDirectory, "session.lock"); BinaryReader datainputstream = new BinaryReader(new FileStream(file, FileMode.Open)); try { if (datainputstream.ReadInt64() != InitializationTime) { throw new MinecraftException("The save is being accessed from another location, aborting"); } } finally { datainputstream.Close(); } } catch (IOException ioexception) { Console.WriteLine(ioexception.ToString()); Console.WriteLine(); throw new MinecraftException("Failed to check session lock, aborting"); } }
public static new Tuple <DirectoryEntry, ImmutableList <ProjectEntry> > Create(DirectoryInfo dir, string relativePath) { var dirsAndProjects = from d in dir.EnumerateDirectories() where !d.IsHidden() && !d.Name.Equals("bin", StringComparison.OrdinalIgnoreCase) && !d.Name.Equals("obj", StringComparison.OrdinalIgnoreCase) orderby d.Name select Create(d, IOPath.Combine(relativePath, d.Name)); var dirs = ImmutableList.CreateBuilder <DirectoryEntry>(); foreach (var dap in dirsAndProjects) { // Discard sub-projects dirs.Add(dap.Item1); } var files = from f in dir.EnumerateFiles() where !f.IsHidden() orderby f.Name select(Entry) FileEntry.Create(f, IOPath.Combine(relativePath, f.Name)); var project = new ProjectEntry(relativePath, false, dir, dirs.ToImmutable(), files.ToImmutableList(), new ReferencesEntry(false, relativePath + ":references", ImmutableList.Create <ReferenceEntry>()), -1); return(new Tuple <DirectoryEntry, ImmutableList <ProjectEntry> >( project, ImmutableList.Create(project))); }
/// <summary> /// @args: Takes two arguments - first the name of the directory containing the world and second the new name for /// that world. @desc: Renames the world by storing the new name in level.dat. It does *not* rename the directory /// containing the world data. /// </summary> public virtual void RenameWorld(string par1Str, string par2Str) { string file = IOPath.Combine(SavesDirectory, par1Str); if (!File.Exists(file)) { return; } string file1 = IOPath.Combine(file, "level.dat"); if (File.Exists(file1)) { try { NBTTagCompound nbttagcompound = CompressedStreamTools.ReadCompressed(new FileStream(file1, FileMode.Open)); NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Data"); nbttagcompound1.SetString("LevelName", par2Str); CompressedStreamTools.WriteCompressed(nbttagcompound, new FileStream(file1, FileMode.Create)); } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } } }
/// <summary> /// par: filename for the level.dat_mcr backup /// </summary> private void createFile(string par1Str) { string file = IOPath.Combine(SavesDirectory, par1Str); //PROBLEMS AHHHHHH if (!File.Exists(file)) { Console.WriteLine("Warning: Unable to create level.dat_mcr backup"); return; } string file1 = IOPath.Combine(file, "level.dat"); if (!File.Exists(file1)) { Console.WriteLine("Warning: Unable to create level.dat_mcr backup"); return; } string file2 = IOPath.Combine(file, "level.dat_mcr"); try { File.Move(file1, file2); } catch (Exception e) { Utilities.LogException(e); Console.WriteLine("Warning: Unable to create level.dat_mcr backup"); } }
public TexturePackList(Minecraft par1Minecraft, string par2File) { availableTexturePacks = new List <TexturePackBase>(); DefaultTexturePack = new TexturePackDefault(par1Minecraft); Field_6538_d = new Dictionary <string, TexturePackBase>(); Mc = par1Minecraft; TexturePackDir = IOPath.Combine(par2File, "Texturepacks"); if (Directory.Exists(TexturePackDir)) { if (File.Exists(TexturePackDir)) { File.Delete(TexturePackDir); Directory.CreateDirectory(TexturePackDir); } } else { Directory.CreateDirectory(TexturePackDir); } CurrentTexturePack = par1Minecraft.GameSettings.Skin; UpdateAvaliableTexturePacks(); SelectedTexturePack.Func_6482_a(); }
public static void OnAssemblyInitialize(TestContext context) { Path = IOPath.GetFullPath(IOPath.Combine(context.TestDir, string.Format("..\\TestLog_{0:yyyy-MM-dd HH_mm_ss}.csv", DateTime.Now))); File.WriteAllLines(Path, new[] { "date-time,duration,result,feature-title,scenario-title" }); }
private void Func_28214_a(string par1File, string par2Str, string par3File) { string file = IOPath.Combine(par1File, par2Str); if (File.Exists(file) && !Directory.Exists(file) && !File.Exists(par3File)) { File.Move(file, par3File); } }
/// <summary> /// Converts the specified map to the new map format. Args: worldName, loadingScreen /// </summary> public override bool ConvertMapFormat(string par1Str, IProgressUpdate par2IProgressUpdate) { par2IProgressUpdate.SetLoadingProgress(0); List <string> arraylist = new List <string>(); List <string> arraylist1 = new List <string>(); List <string> arraylist2 = new List <string>(); string file = IOPath.Combine(SavesDirectory, par1Str); string file1 = IOPath.Combine(file, "DIM-1"); string file2 = IOPath.Combine(file, "DIM1"); Console.WriteLine("Scanning folders..."); Func_48432_a(file, arraylist); if (File.Exists(file1)) { Func_48432_a(file1, arraylist1); } if (File.Exists(file2)) { Func_48432_a(file2, arraylist2); } int i = arraylist.Count + arraylist1.Count + arraylist2.Count; Console.WriteLine((new StringBuilder()).Append("Total conversion count is ").Append(i).ToString()); WorldInfo worldinfo = GetWorldInfo(par1Str); object obj = null; if (worldinfo.GetTerrainType() == WorldType.FLAT) { obj = new WorldChunkManagerHell(BiomeGenBase.Plains, 0.5F, 0.5F); } else { obj = new WorldChunkManager(worldinfo.GetSeed(), worldinfo.GetTerrainType()); } Func_48428_a(IOPath.Combine(file, "region"), arraylist, ((WorldChunkManager)(obj)), 0, i, par2IProgressUpdate); Func_48428_a(IOPath.Combine(file1, "region"), arraylist1, new WorldChunkManagerHell(BiomeGenBase.Hell, 1.0F, 0.0F), arraylist.Count, i, par2IProgressUpdate); Func_48428_a(IOPath.Combine(file2, "region"), arraylist2, new WorldChunkManagerHell(BiomeGenBase.Sky, 0.5F, 0.0F), arraylist.Count + arraylist1.Count, i, par2IProgressUpdate); worldinfo.SetSaveVersion(19133); if (worldinfo.GetTerrainType() == WorldType.DEFAULT_1_1) { worldinfo.SetTerrainType(WorldType.DEFAULT); } createFile(par1Str); ISaveHandler isavehandler = GetSaveLoader(par1Str, false); isavehandler.SaveWorldInfo(worldinfo); return(true); }
private void Func_48432_a(string par1File, List <string> par2ArrayList) { string[] afile = Directory.GetFiles(IOPath.Combine(par1File, "region"), AnvilSaveConverterFileFilter.SearchString); if (afile != null) { for (int i = 0; i < afile.Length; i++) { par2ArrayList.Add(afile[i]); } } }
/// <summary> /// gets the world info /// </summary> public virtual WorldInfo GetWorldInfo(string par1Str) { string file = IOPath.Combine(SavesDirectory, par1Str); if (!Directory.Exists(file)) { return(null); } string file1 = IOPath.Combine(file, "level.dat"); if (File.Exists(file1)) { try { MemoryStream stream = new MemoryStream(); using (var fs = new FileStream(file1, FileMode.Open)) { fs.CopyTo(stream); } stream.Seek(0, SeekOrigin.Begin); NBTTagCompound nbttagcompound = CompressedStreamTools.ReadCompressed(stream); NBTTagCompound nbttagcompound2 = nbttagcompound.GetCompoundTag("Data"); return(new WorldInfo(nbttagcompound2)); } catch (Exception exception) { Utilities.LogException(exception); } } file1 = IOPath.Combine(file, "level.dat_old"); if (File.Exists(file1)) { try { NBTTagCompound nbttagcompound1 = CompressedStreamTools.ReadCompressed(new FileStream(file1, FileMode.Open)); NBTTagCompound nbttagcompound3 = nbttagcompound1.GetCompoundTag("Data"); return(new WorldInfo(nbttagcompound3)); } catch (Exception exception1) { Utilities.LogException(exception1); } } return(null); }
/// <summary> /// @args: Takes one argument - the name of the directory of the world to delete. @desc: Delete the world by deleting /// the associated directory recursively. /// </summary> public virtual void DeleteWorldDirectory(string par1Str) { string file = IOPath.Combine(SavesDirectory, par1Str); if (!Directory.Exists(file)) { return; } else { Directory.Delete(file, true); return; } }
public SaveHandler(string par1File, string par2Str, bool par3) { SaveDirectory = IOPath.Combine(par1File, par2Str); Directory.CreateDirectory(SaveDirectory); PlayersDirectory = IOPath.Combine(SaveDirectory, "players"); MapDataDir = IOPath.Combine(SaveDirectory, "data"); Directory.CreateDirectory(MapDataDir); SaveDirectoryName = par2Str; if (par3) { Directory.CreateDirectory(PlayersDirectory); } SetSessionLock(); }
//根据歌曲,获取歌词 private List <Lynic> GetLynicBySong(Song s) { string lynicFile1 = IOPath.Combine(IOPath.GetDirectoryName(s.Location), IOPath.GetFileNameWithoutExtension(s.Location) + ".lrc"); string lynicFile2 = IOPath.Combine(IOPath.GetDirectoryName(s.Location), "Lynic", IOPath.GetFileNameWithoutExtension(s.Location) + ".lrc"); if (File.Exists(lynicFile1)) { return(EntityService.GetLynics(lynicFile1)); } else if (File.Exists(lynicFile2)) { return(EntityService.GetLynics(lynicFile2)); } else { return(null); } }
/// <summary> /// Saves the passed in world info. /// </summary> public virtual void SaveWorldInfo(WorldInfo par1WorldInfo) { NBTTagCompound nbttagcompound = par1WorldInfo.GetNBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.SetTag("Data", nbttagcompound); try { string file = IOPath.Combine(SaveDirectory, "level.dat_new"); string file1 = IOPath.Combine(SaveDirectory, "level.dat_old"); string file2 = IOPath.Combine(SaveDirectory, "level.dat"); CompressedStreamTools.WriteCompressed(nbttagcompound1, new FileStream(file, FileMode.Create)); if (File.Exists(file1)) { File.Delete(file1); } File.Move(file2, file1); if (File.Exists(file2)) { File.Delete(file2); } File.Move(file, file2); if (File.Exists(file)) { File.Delete(file); } } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } }
/// <summary> /// Returns the chunk loader with the provided world provider /// </summary> public override IChunkLoader GetChunkLoader(WorldProvider par1WorldProvider) { string directory = GetSaveDirectory(); if (par1WorldProvider is WorldProviderHell) { string directory1 = IOPath.Combine(directory, "DIM-1"); Directory.CreateDirectory(directory1); return(new AnvilChunkLoader(directory1)); } if (par1WorldProvider is WorldProviderEnd) { string directory2 = IOPath.Combine(directory, "DIM1"); Directory.CreateDirectory(directory2); return(new AnvilChunkLoader(directory2)); } else { return(new AnvilChunkLoader(directory)); } }
/// <summary> /// Loads and returns the world info /// </summary> public virtual WorldInfo LoadWorldInfo() { string file = IOPath.Combine(SaveDirectory, "level.dat"); if (File.Exists(file)) { try { NBTTagCompound nbttagcompound = CompressedStreamTools.ReadCompressed(new FileStream(file, FileMode.Open)); NBTTagCompound nbttagcompound2 = nbttagcompound.GetCompoundTag("Data"); return(new WorldInfo(nbttagcompound2)); } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } } file = IOPath.Combine(SaveDirectory, "level.dat_old"); if (File.Exists(file)) { try { NBTTagCompound nbttagcompound1 = CompressedStreamTools.ReadCompressed(new FileStream(file, FileMode.Open)); NBTTagCompound nbttagcompound3 = nbttagcompound1.GetCompoundTag("Data"); return(new WorldInfo(nbttagcompound3)); } catch (Exception exception1) { Console.WriteLine(exception1.ToString()); Console.Write(exception1.StackTrace); } } return(null); }
/// <summary> /// Creates a session lock file for this process /// </summary> private void SetSessionLock() { try { string file = IOPath.Combine(SaveDirectory, "session.lock"); BinaryWriter dataoutputstream = new BinaryWriter(new FileStream(file, FileMode.Create)); try { dataoutputstream.Write(InitializationTime); } finally { dataoutputstream.Close(); } } catch (IOException ioexception) { Console.WriteLine(ioexception.ToString()); Console.Write(ioexception.StackTrace); throw new Exception("Failed to check session lock, aborting"); } }
public TempDir() { Path = IOPath.Combine(IOPath.GetTempPath(), Guid.NewGuid().ToString("n")); Directory.CreateDirectory(Path); }
private void Func_48430_a(string par1File, string par2File, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate) { try { FileInfo file = new FileInfo(par2File); string s = file.Name; RegionFile regionfile = new RegionFile(par2File); RegionFile regionfile1 = new RegionFile(IOPath.Combine(par1File, (new StringBuilder()).Append(s.Substring(0, s.Length - ".mcr".Length)).Append(".mca").ToString())); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { if (!regionfile.IsChunkSaved(i, j) || regionfile1.IsChunkSaved(i, j)) { continue; } Stream datainputstream = regionfile.GetChunkFileStream(i, j); if (datainputstream == null) { Console.WriteLine("Failed to fetch input stream"); } else { NBTTagCompound nbttagcompound = CompressedStreamTools.Read(new BinaryReader(datainputstream)); datainputstream.Close(); NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Level"); AnvilConverterData anvilconverterdata = ChunkLoader.Load(nbttagcompound1); NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); nbttagcompound2.SetTag("Level", nbttagcompound3); ChunkLoader.ConvertToAnvilFormat(anvilconverterdata, nbttagcompound3, par3WorldChunkManager); Stream dataoutputstream = regionfile1.GetChunkDataOutputStream(i, j); CompressedStreamTools.Write(nbttagcompound2, new BinaryWriter(dataoutputstream)); dataoutputstream.Close(); } } int k = (int)Math.Round((100D * (double)(par4 * 1024)) / (double)(par5 * 1024)); int l = (int)Math.Round((100D * (double)((i + 1) * 32 + par4 * 1024)) / (double)(par5 * 1024)); if (l > k) { par6IProgressUpdate.SetLoadingProgress(l); } } regionfile.Close(); regionfile1.Close(); } catch (IOException ioexception) { Utilities.LogException(ioexception); } }
/// <summary> /// check the texture packs the client has installed /// </summary> public virtual void UpdateAvaliableTexturePacks() { List <TexturePackBase> arraylist = new List <TexturePackBase>(); SelectedTexturePack = null; arraylist.Add(DefaultTexturePack); if (Directory.Exists(TexturePackDir)) { string[] afile = Directory.GetFiles(TexturePackDir); string[] afile1 = afile; int i = afile1.Length; for (int j = 0; j < i; j++) { FileInfo file = new FileInfo(afile1[j]); if (file.Name.ToLower().EndsWith(".zip")) { string s = (new StringBuilder()).Append(file.Name).Append(":").Append(file.Length).Append(":").Append(file.LastWriteTime).ToString(); try { if (!Field_6538_d.ContainsKey(s)) { TexturePackCustom texturepackcustom = new TexturePackCustom(file.FullName); texturepackcustom.TexturePackID = s; Field_6538_d[s] = texturepackcustom; texturepackcustom.Func_6485_a(Mc); } TexturePackBase texturepackbase1 = Field_6538_d[s]; if (texturepackbase1.TexturePackFileName.Equals(CurrentTexturePack)) { SelectedTexturePack = texturepackbase1; } arraylist.Add(texturepackbase1); } catch (IOException ioexception) { Console.WriteLine(ioexception.ToString()); Console.Write(ioexception.StackTrace); } continue; } if (!Directory.Exists(file.FullName) || !File.Exists(IOPath.Combine(file.FullName, "pack.txt"))) { continue; } string s1 = (new StringBuilder()).Append(file.Name).Append(":folder:").Append(file.LastWriteTime).ToString(); try { if (!Field_6538_d.ContainsKey(s1)) { TexturePackFolder texturepackfolder = new TexturePackFolder(file.FullName); texturepackfolder.TexturePackID = s1; Field_6538_d[s1] = texturepackfolder; texturepackfolder.Func_6485_a(Mc); } TexturePackBase texturepackbase2 = Field_6538_d[s1]; if (texturepackbase2.TexturePackFileName.Equals(CurrentTexturePack)) { SelectedTexturePack = texturepackbase2; } arraylist.Add(texturepackbase2); } catch (IOException ioexception1) { Console.WriteLine(ioexception1.ToString()); Console.WriteLine(); } } } if (SelectedTexturePack == null) { SelectedTexturePack = DefaultTexturePack; } //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method: foreach (TexturePackBase t in arraylist) { availableTexturePacks.Remove(t); } TexturePackBase texturepackbase; for (IEnumerator <TexturePackBase> iterator = availableTexturePacks.GetEnumerator(); iterator.MoveNext(); Field_6538_d.Remove(texturepackbase.TexturePackID)) { texturepackbase = iterator.Current; texturepackbase.UnbindThumbnailTexture(Mc); } availableTexturePacks = arraylist; }
/// <summary> /// Gets the file location of the given map /// </summary> public virtual string GetMapFileFromName(string par1Str) { return(IOPath.Combine(MapDataDir, (new StringBuilder()).Append(par1Str).Append(".dat").ToString())); }