renameTo() private method

private renameTo ( global par0 ) : bool
par0 global
return bool
Exemplo n.º 1
0
 public virtual void writePlayerData(EntityPlayer entityplayer)
 {
     try
     {
         var nbttagcompound = new NBTTagCompound();
         entityplayer.writeToNBT(nbttagcompound);
         var file = new File(worldFile, "_tmp_.dat");
         var file1 = new File(worldFile,
                              (new StringBuilder()).append(entityplayer.username).append(".dat").toString());
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, new FileOutputStream(file));
         if (file1.exists())
         {
             file1.delete();
         }
         file.renameTo(file1);
     }
     catch (Exception)
     {
         logger.warning(
             (new StringBuilder()).append("Failed to save player data for ").append(entityplayer.username).
                 toString());
     }
 }
Exemplo n.º 2
0
 public virtual void func_22094_a(WorldInfo worldinfo)
 {
     NBTTagCompound nbttagcompound = worldinfo.func_22185_a();
     var nbttagcompound1 = new NBTTagCompound();
     nbttagcompound1.setTag("Data", nbttagcompound);
     try
     {
         var file = new File(field_22099_b, "level.dat_new");
         var file1 = new File(field_22099_b, "level.dat_old");
         var file2 = new File(field_22099_b, "level.dat");
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound1, new FileOutputStream(file));
         if (file1.exists())
         {
             file1.delete();
         }
         file2.renameTo(file1);
         if (file2.exists())
         {
             file2.delete();
         }
         file.renameTo(file2);
         if (file.exists())
         {
             file.delete();
         }
     }
     catch (Exception exception)
     {
         exception.printStackTrace();
     }
 }
Exemplo n.º 3
0
 public void saveChunk(World world, Chunk chunk)
 {
     world.checkSessionLock();
     File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition);
     if (file.exists())
     {
         WorldInfo worldinfo = world.getWorldInfo();
         worldinfo.func_22177_b(worldinfo.func_22182_g() - file.length());
     }
     try
     {
         var file1 = new File(saveDir, "tmp_chunk.dat");
         var fileoutputstream = new FileOutputStream(file1);
         var nbttagcompound = new NBTTagCompound();
         var nbttagcompound1 = new NBTTagCompound();
         nbttagcompound.setTag("Level", nbttagcompound1);
         storeChunkInCompound(chunk, world, nbttagcompound1);
         CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, fileoutputstream);
         fileoutputstream.close();
         if (file.exists())
         {
             file.delete();
         }
         file1.renameTo(file);
         WorldInfo worldinfo1 = world.getWorldInfo();
         worldinfo1.func_22177_b(worldinfo1.func_22182_g() + file.length());
     }
     catch (Exception exception)
     {
         exception.printStackTrace();
     }
 }