Hierarchy 개발 중

This commit is contained in:
logonkhi
2025-10-28 15:36:55 +09:00
parent fdfc6cf727
commit a356c5497a
25 changed files with 4855 additions and 145 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Collections;
@@ -951,10 +951,10 @@ public class lzip {
}
// This function returns the index of an entry assuming the getFileInfo function was called prior on a zip file.
// This function returns the index of an ItemPrefab assuming the getFileInfo function was called prior on a zip file.
//
// entry: the entry for which we want to get the index.
// Returns -1 if no entry was found in the List.
// ItemPrefab: the ItemPrefab for which we want to get the index.
// Returns -1 if no ItemPrefab was found in the List.
public static int getEntryIndex(string entry) {
if(ninfo == null || ninfo.Count == 0) return -1;
@@ -1056,7 +1056,7 @@ public class lzip {
// A function that returns the uncompressed size of a file in a zip archive.
//
// zipArchive : the zip archive to get the info from.
// entry : the entry for which we want to know it uncompressed size.
// ItemPrefab : the ItemPrefab for which we want to know it uncompressed size.
// FileBuffer : A buffer that holds a zip file. When assigned the function will read from this buffer and will ignore the filePath.
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
//
@@ -1085,12 +1085,12 @@ public class lzip {
}
// A function that tells if an entry in zip archive exists.
// A function that tells if an ItemPrefab in zip archive exists.
//
// Returns true or false.
//
// zipArchive : the zip archive to get the info from.
// entry : the entry for which we want to know if it exists.
// ItemPrefab : the ItemPrefab for which we want to know if it exists.
// FileBuffer : A buffer that holds a zip file. When assigned the function will read from this buffer and will ignore the filePath.
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
//
@@ -1141,8 +1141,8 @@ public class lzip {
// arcFilename : the name of the file that will be written to the archive.
// buffer : the buffer that will be compressed and will be put in the zip archive.
// append : set to true if you want the output to be appended to an existing zip archive.
// comment : an optional comment for this entry.
// password : an optional password to encrypt this entry.
// comment : an optional comment for this ItemPrefab.
// password : an optional password to encrypt this ItemPrefab.
// useBz2 : set to true if you want bz2 compression instead of zlib. (not available for MacOS/iOS/tvOS)
//
// ERROR CODES : true = success
@@ -1189,12 +1189,12 @@ public class lzip {
}
// A function that replaces an entry in a zip archive with a file that lies in a path. The original name of the archive will be used. Does not work on password protected archives.
// A function that replaces an ItemPrefab in a zip archive with a file that lies in a path. The original name of the archive will be used. Does not work on password protected archives.
//
// zipArchive : the full path to the zip archive
// arcFilename : the name of the file that will be replaced.
// newFilePath : a path to the file that will replace the original entry.
// level: : the level of compression of the new entry. (0 = Store method.)
// newFilePath : a path to the file that will replace the original ItemPrefab.
// level: : the level of compression of the new ItemPrefab. (0 = Store method.)
// comment : add a comment for the file in the zip file header.
// password : set the password to protect this file.
// useBz2 : use the bz2 compression algorithm. If false the zlib deflate algorithm will be used. (not available for MacOS/iOS/tvOS)
@@ -1202,7 +1202,7 @@ public class lzip {
// ERROR CODES
// : -1 = could not create or append
// : -2 = error during operation
// : -3 = failed to delete original entry
// : -3 = failed to delete original ItemPrefab
//
public static int replace_entry(string zipArchive, string arcFilename, string newFilePath, int level = 9, string comment = null, string password = null, bool useBz2 = false) {
@@ -1213,12 +1213,12 @@ public class lzip {
return zipCD(level, @zipArchive, newFilePath, @arcFilename, comment, password, useBz2, 0, IntPtr.Zero);
}
// A function that replaces an entry in a zip archive with a buffer. The original name of the archive will be used. Does not work on password protected archives.
// A function that replaces an ItemPrefab in a zip archive with a buffer. The original name of the archive will be used. Does not work on password protected archives.
//
// zipArchive : the full path to the zip archive
// arcFilename : the name of the file that will be replaced.
// newFileBuffer : a byte buffer that will replace the original entry.
// level: : the level of compression of the new entry. (0 = Store method.)
// newFileBuffer : a byte buffer that will replace the original ItemPrefab.
// level: : the level of compression of the new ItemPrefab. (0 = Store method.)
// password : set the password to protect this file.
// useBz2 : use the bz2 compression algorithm. If false the zlib deflate algorithm will be used. (not available for MacOS/iOS/tvOS)
//
@@ -1246,12 +1246,12 @@ public class lzip {
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
// proc: : a single item ulong array that gets updated with the progress of the decompression in bytes.
// (100% is reached when the decompressed size of the file is reached.)
// password : if needed, the password to decrypt the entry.
// password : if needed, the password to decrypt the ItemPrefab.
//
// ERROR CODES : -1 = extraction failed
// : -2 = could not initialize zip archive.
// : -3 = could not locate entry
// : -4 = could not get entry info
// : -3 = could not locate ItemPrefab
// : -4 = could not get ItemPrefab info
// : -5 = password error
// : -6 = non valid zip size when using native file buffer
// : -7 = output directory does not exist or could not be created
@@ -1306,11 +1306,11 @@ public class lzip {
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
// proc : a single item ulong array that gets updated with the progress of the decompression in bytes.
// (100% is reached when the decompressed size of the file is reached.)
// password : if needed, the password to decrypt the entry.
// password : if needed, the password to decrypt the ItemPrefab.
//
// ERROR CODES : -2 = could not initialize zip archive.
// : -3 = fileList provided is null.
// : -4 = could not get entry info
// : -4 = could not get ItemPrefab info
// : -5 = password error
// : -6 = non valid zip size when using native file buffer
// : -7 = output directory does not exist or could not be created
@@ -1742,18 +1742,18 @@ public class lzip {
return res;
}
// Extract an entry from a tar archive
// Extract an ItemPrefab from a tar archive
//
// inFile : the full path to our tar archive
// entry : the entry we want to extract. (If the file resides in a directory, the directory path should be included. like dir1/dir2/myfile.bin)
// outPath : the path in which want to extract our entry. If null the same path as the inFile will be used.
// fullPaths : if the entry resides in a directory, use this flag to create the directory structure or not.
// ItemPrefab : the ItemPrefab we want to extract. (If the file resides in a directory, the directory path should be included. like dir1/dir2/myfile.bin)
// outPath : the path in which want to extract our ItemPrefab. If null the same path as the inFile will be used.
// fullPaths : if the ItemPrefab resides in a directory, use this flag to create the directory structure or not.
// ! If it is set to false, you can use an absolute path in the outPath parameter to extract with a different filename !
// byteProgress : a sigle item ulong array that will get updated with the bytes of the extraction progress. Use in a Thread for real time report.
//
// Error codes : -1 could not find input file.
// : -3 could not write output file.
// : -5 could not find entry
// : -5 could not find ItemPrefab
// : -8 canceled
// : 1 Success
@@ -1945,14 +1945,14 @@ public class lzip {
#endif
// get the DateTime of an entry in a zip archive
// get the DateTime of an ItemPrefab in a zip archive
//
// zipArchive : the full path to the zip archive from which we want to extract the specific file.
// entry : the specific entry we want to get the DateTime of. (If the entry resides in a directory, the directory path should be included. like dir1/dir2/myfile.bin)
// ItemPrefab : the specific ItemPrefab we want to get the DateTime of. (If the ItemPrefab resides in a directory, the directory path should be included. like dir1/dir2/myfile.bin)
// FileBuffer : A buffer that holds a zip file. When assigned the function will read from this buffer and will ignore the zipArchive path.
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, then the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
//
// Returns the date and time of the entry in DateTime format.
// Returns the date and time of the ItemPrefab in DateTime format.
//
public static DateTime entryDateTime(string zipArchive, string entry, object fileBuffer = null) {
@@ -2070,7 +2070,7 @@ public class lzip {
if(t.zf != IntPtr.Zero) return true; else return false;
}
// A function that adds a buffer as a zip entry in an opened inMemory zip archive with the inMemoryZipStart function.
// A function that adds a buffer as a zip ItemPrefab in an opened inMemory zip archive with the inMemoryZipStart function.
//
// t : the inMemory class that holds the pointer to our inMemory zip file.
// levelOfCompression : (0-9) recommended 9 for maximum (0 = Store method.)
@@ -2084,7 +2084,7 @@ public class lzip {
// Returns 0 on success.
public static int inMemoryZipAdd(inMemory t, int levelOfCompression, byte[] buffer, string fileName, string comment = null, string password = null, bool useBz2 = false) {
if(t.info == null) { Debug.Log("inMemory object is null"); return -1; }
if (t.isClosed) { Debug.Log("Can't add entry. inMemory zip is closed."); return -2; }
if (t.isClosed) { Debug.Log("Can't add ItemPrefab. inMemory zip is closed."); return -2; }
if (password == "") password = null;
if (comment == "") comment = null;
if (fileName == null) fileName = "";
@@ -2192,16 +2192,16 @@ public class lzip {
// A function that will decompress a file from an inmemory zip file pointer directly in a provided byte buffer.
//
// t : the inMemory class that holds the pointer to our inMemory zip file.
// entry : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// ItemPrefab : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// buffer : a referenced byte buffer that will be resized and will be filled with the extraction data.
// password : If the archive is encrypted use a password.
//
// ERROR CODES : 1 = success
// : -2 = could not find/open zip file
// : -3 = could not locate entry
// : -4 = could not get entry info
// : -3 = could not locate ItemPrefab
// : -4 = could not get ItemPrefab info
// : -5 = password error
// : -18 = the entry has no size
// : -18 = the ItemPrefab has no size
// : -104 = internal memory error
//
public static int entry2BufferMem(inMemory t, string entry, ref byte[] buffer, string password = null) {
@@ -2226,7 +2226,7 @@ public class lzip {
// A function that will decompress a file from an inmemory zip file pointer to a new created and returned byte buffer.
//
// t : the inMemory class that holds the pointer to our inMemory zip file.
// entry : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.
// ItemPrefab : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.
// password : If the archive is encrypted use a password.
//
// ERROR CODES : non-null = success
@@ -2254,19 +2254,19 @@ public class lzip {
// A function that will decompress a file from an inmemory zip file pointer directly to a provided fixed size byte buffer.
//
// Returns the uncompressed size of the entry.
// Returns the uncompressed size of the ItemPrefab.
//
// t : the inMemory class that holds the pointer to our inMemory zip file.
// entry : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// ItemPrefab : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// buffer : a referenced fixed size byte buffer that will be filled with the extraction data. It should be large enough to store the data.
// password : if the archive is encrypted use a password.
//
// ERROR CODES : 1 = success
// : -2 = could not find/open zip archive
// : -3 = could not locate entry
// : -4 = could not get entry info
// : -3 = could not locate ItemPrefab
// : -4 = could not get ItemPrefab info
// : -5 = password error
// : -18 = the entry has no size
// : -18 = the ItemPrefab has no size
// : -19 = the fixed size buffer is not big enough to store the uncompressed data
// : -104 = internal memory error
//
@@ -2368,7 +2368,7 @@ public class lzip {
// A function that will decompress a file in a zip archive directly to a provided byte buffer.
//
// zipArchive : the full path to the zip archive from which a specific file will be extracted to a byte buffer.
// entry : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// ItemPrefab : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// buffer : a referenced byte buffer that will be resized and will be filled with the extraction data.
// FileBuffer : A buffer that holds a zip file. When assigned the function will read from this buffer and will ignore the filePath.
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, then the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
@@ -2376,11 +2376,11 @@ public class lzip {
//
// ERROR CODES : 1 = success
// : -2 = could not find/open zip archive
// : -3 = could not locate entry
// : -4 = could not get entry info
// : -3 = could not locate ItemPrefab
// : -4 = could not get ItemPrefab info
// : -5 = password error
// : -6 = non valid zip size when using native file buffer
// : -18 = the entry has no size
// : -18 = the ItemPrefab has no size
// : -104 = internal memory error
//
public static int entry2Buffer(string zipArchive, string entry, ref byte[] buffer, object fileBuffer = null, string password = null) {
@@ -2439,10 +2439,10 @@ public class lzip {
// A function that will decompress a file in a zip archive directly to a provided fixed size byte buffer.
//
// Returns the uncompressed size of the entry.
// Returns the uncompressed size of the ItemPrefab.
//
// zipArchive : the full path to the zip archive from which a specific file will be extracted to a byte buffer.
// entry : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// ItemPrefab : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.)
// buffer : a referenced fixed size byte buffer that will be filled with the extraction data. It should be large enough to store the data.
// FileBuffer : a buffer that holds a zip file. When assigned the function will read from this buffer and will ignore the filePath.
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, then the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
@@ -2450,11 +2450,11 @@ public class lzip {
//
// ERROR CODES : number of extracted bytes = success
// : -2 = could not find/open zip archive
// : -3 = could not locate entry
// : -4 = could not get entry info
// : -3 = could not locate ItemPrefab
// : -4 = could not get ItemPrefab info
// : -5 = password error
// : -6 = non valid zip size when using native file buffer
// : -18 = the entry has no size
// : -18 = the ItemPrefab has no size
// : -19 = the fixed size buffer is not big enough to store the uncompressed data
// : -104 = internal memory error
//
@@ -2518,7 +2518,7 @@ public class lzip {
// A function that will decompress a file in a zip archive to a new created and returned byte buffer.
//
// zipArchive : the full path to the zip archive from which a specific file will be extracted to a byte buffer.
// entry : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.
// ItemPrefab : the file we want to extract to a buffer. (If the file resides in a directory, the directory should be included.
// FileBuffer : A buffer that holds a zip file. When assigned the function will read from this buffer and will ignore the filePath.
// : Can be a c# byte[] buffer or an unmanaged Inptr buffer or an inMemory class! When an IntPtr is used, then the zipArchive string parameter will be used to pass the Length of the Intptr buffer!
// password : If the archive is encrypted use a password.
@@ -2622,7 +2622,7 @@ public class lzip {
//
// ---------------------------------------------------------------------------------------------------------------------------------
// a struct to store zip entry information
// a struct to store zip ItemPrefab information
public struct zipInfo{
public short VersionMadeBy;
public short MinimumVersionToExtract;
@@ -2674,12 +2674,12 @@ public class lzip {
return false;
}
// Get position, size and/or entry info of a zip archive in the file system.
// Get position, size and/or ItemPrefab info of a zip archive in the file system.
// This function is mainly useful to discover a zip archive hidden or merged in another bigger archive.
// filename: the path to the archive.
// ref pos: the position in bytes of the zip archive.
// ref size: the size of the zip archive.
// If getCentralDirectory is set to true it will fill the zinfo List with extended entry information.
// If getCentralDirectory is set to true it will fill the zinfo List with extended ItemPrefab information.
// For now it does not work with zip64.
// Returns true on success.
public static bool getZipInfoMerged(string fileName, ref int pos, ref int size, bool getCentralDirectory = false) {
@@ -2704,12 +2704,12 @@ public class lzip {
}
#endif
// Get position, size and/or entry info of a zip archive in a buffer.
// Get position, size and/or ItemPrefab info of a zip archive in a buffer.
// This function is mainly useful to discover a zip archive hidden or merged in another bigger buffer.
// buffer: the buffer where the merged zip archive resides.
// ref pos: the position in bytes of the zip archive.
// ref size: the size of the zip archive.
// If getCentralDirectory is set to true it will fill the zinfo List with extended entry information.
// If getCentralDirectory is set to true it will fill the zinfo List with extended ItemPrefab information.
// For now it does not work with zip64.
// Returns true on success.
public static bool getZipInfoMerged(byte[] buffer, ref int pos, ref int size, bool getCentralDirectory = false) {
@@ -2779,7 +2779,7 @@ public class lzip {
return res;
}
// Read central directory basics and find position and size of the zip archive in stream. Returns entry count.
// Read central directory basics and find position and size of the zip archive in stream. Returns ItemPrefab count.
private static int findEnd(BinaryReader reader, ref int pos, ref int size) {
long origin = reader.BaseStream.Position;
@@ -2823,7 +2823,7 @@ public class lzip {
return result;
}
// Read info for each entry in the zip archive and store it in zinfo List.
// Read info for each ItemPrefab in the zip archive and store it in zinfo List.
private static void getCentralDir(BinaryReader reader, int count) {
if(zinfo != null && zinfo.Count > 0) zinfo.Clear();
@@ -3055,17 +3055,17 @@ public class lzip {
File.WriteAllBytes(outPath + "/" + fn, tb);
res = 1;
} else {
Debug.Log("Could not extract entry.");
Debug.Log("Could not extract ItemPrefab.");
}
}
// Extract an entry from a merged zip that resides in the file system to disk.
// Extract an ItemPrefab from a merged zip that resides in the file system to disk.
// Returns 1 on success.
//
// file : the path to the file where the zip archive resides.
// entry : the entry to extract.
// outPath : the path where the entry will be extracted.
// overrideEntryName : with this you can override the default entry name.
// ItemPrefab : the ItemPrefab to extract.
// outPath : the path where the ItemPrefab will be extracted.
// overrideEntryName : with this you can override the default ItemPrefab name.
// password : if needed, the password to decrypt the archive.
public static int entry2FileMerged(string file, string entry, string outPath, string overrideEntryName = null, string password = null) {
@@ -3099,13 +3099,13 @@ public class lzip {
}
// Extract an entry from a merged zip that resides in a buffer to disk.
// Extract an ItemPrefab from a merged zip that resides in a buffer to disk.
// Returns 1 on success.
//
// buffer : the buffer where the zip archive resides.
// entry : the entry to extract.
// outPath : the path where the entry will be extracted.
// overrideEntryName : with this you can override the default entry name.
// ItemPrefab : the ItemPrefab to extract.
// outPath : the path where the ItemPrefab will be extracted.
// overrideEntryName : with this you can override the default ItemPrefab name.
// password : if needed, the password to decrypt the archive.
public static int entry2FileMerged(byte[] buffer, string entry, string outPath, string overrideEntryName = null, string password = null) {
@@ -3139,10 +3139,10 @@ public class lzip {
}
// A function that extracts an entry from a zip archive that is merged/hidden in the file system and returns the extracted data in a new buffer.
// A function that extracts an ItemPrefab from a zip archive that is merged/hidden in the file system and returns the extracted data in a new buffer.
//
// file : the path to the file where the zip archive resides.
// entry : the entry to extract.
// ItemPrefab : the ItemPrefab to extract.
// password : if needed, the password to decrypt the archive.
public static byte[] entry2BufferMerged(string file, string entry, string password = null) {
@@ -3170,10 +3170,10 @@ public class lzip {
return null;
}
// A function that extracts an entry from a zip archive that is merged/hidden in the file system and returns the extracted data in a referenced buffer that will get resized to fit the data.
// A function that extracts an ItemPrefab from a zip archive that is merged/hidden in the file system and returns the extracted data in a referenced buffer that will get resized to fit the data.
//
// file : the path to the file where the zip archive resides.
// entry : the entry to extract.
// ItemPrefab : the ItemPrefab to extract.
// refBuffer : the referenced buffer that will get resized to store the decompressed data.
// password : if needed, the password to decrypt the archive.
public static int entry2BufferMerged(string file, string entry, ref byte[] refBuffer, string password = null) {
@@ -3202,10 +3202,10 @@ public class lzip {
return 0;
}
// A function that extracts an entry from a zip archive that is merged/hidden in the file system and writes the extracted data in a fixed size buffer.
// A function that extracts an ItemPrefab from a zip archive that is merged/hidden in the file system and writes the extracted data in a fixed size buffer.
//
// file : the path to the file where the zip archive resides.
// entry : the entry to extract.
// ItemPrefab : the ItemPrefab to extract.
// fixedBuffer : the fixed sized buffer where the data will be written.
// password : if needed, the password to decrypt the archive.
public static int entry2FixedBufferMerged(string file, string entry, ref byte[] fixedBuffer, string password = null) {
@@ -3235,10 +3235,10 @@ public class lzip {
}
#endif
// A function that extracts an entry from a zip archive that is merged/hidden in a buffer and returns the extracted data in a new buffer.
// A function that extracts an ItemPrefab from a zip archive that is merged/hidden in a buffer and returns the extracted data in a new buffer.
//
// buffer : the buffer where the zip archive resides.
// entry : the entry to extract.
// ItemPrefab : the ItemPrefab to extract.
// password : if needed, the password to decrypt the archive.
public static byte[] entry2BufferMerged(byte[] buffer, string entry, string password = null) {
@@ -3263,10 +3263,10 @@ public class lzip {
return null;
}
// A function that extracts an entry from a zip archive that is merged/hidden in a buffer and returns the extracted data in a referenced buffer that will get resized to fit the data.
// A function that extracts an ItemPrefab from a zip archive that is merged/hidden in a buffer and returns the extracted data in a referenced buffer that will get resized to fit the data.
//
// buffer : the buffer where the zip archive resides.
// entry : the entry to extract.
// ItemPrefab : the ItemPrefab to extract.
// refBuffer : the referenced buffer that will get resized to store the decompressed data.
// password : if needed, the password to decrypt the archive.
public static int entry2BufferMerged(byte[] buffer, string entry, ref byte[] refBuffer, string password = null) {
@@ -3292,11 +3292,11 @@ public class lzip {
return 0;
}
// A function that extracts an entry from a zip archive that is merged/hidden in a buffer and writes the extracted data in a fixed size buffer.
// A function that extracts an ItemPrefab from a zip archive that is merged/hidden in a buffer and writes the extracted data in a fixed size buffer.
// Returns the size of the uncompressed data.
//
// buffer : the buffer where the zip archive resides.
// entry : the entry to extract.
// ItemPrefab : the ItemPrefab to extract.
// fixedBuffer : the fixed sized buffer where the data will be written.
// password : if needed, the password to decrypt the archive.
// ERROR CODES

View File

@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System;
using System.Text;
using System.Threading;
@@ -195,19 +195,19 @@ public class testZip : MonoBehaviour
plog("true total entries: "+lzip.getTotalEntries(ppath + "/testZip.zip"));
// entry exists
// ItemPrefab exists
bool eres = lzip.entryExists(ppath + "/testZip.zip", "dir1/dir2/test2.bmp");
plog("entry exists: " + eres.ToString());
plog("ItemPrefab exists: " + eres.ToString());
// get entry dateTime
// get ItemPrefab dateTime
plog();
plog("DateTime: " + lzip.entryDateTime(ppath + "/testZip.zip", "dir1/dir2/test2.bmp").ToString());
// extract an entry
// extract an ItemPrefab
zres = lzip.extract_entry(ppath + "/testZip.zip", "dir1/dir2/test2.bmp", ppath + "/test22P.bmp", null, progress2);
plog("extract entry: " + zres.ToString());
plog("extract ItemPrefab: " + zres.ToString());
plog();
// extract entries using a List
@@ -244,7 +244,7 @@ public class testZip : MonoBehaviour
lzip.getFileInfo(ppath + "/test2Zip.zip");
// then we get the offset to the uncompressed data and the uncompressed size of the file.
// get the index of our entry in the info lists
// get the index of our ItemPrefab in the info lists
int index = lzip.getEntryIndex("dir1/dir2/dir3/Unity_1.jpg");
// if we got a valid index we are going to extract our archive without zip operations
@@ -331,7 +331,7 @@ public class testZip : MonoBehaviour
// get the uncompressed size of a specific file in the zip archive
plog("get entry size: " + lzip.getEntrySize(ppath + "/testZip.zip", "dir1/dir2/test2.bmp").ToString());
plog("get ItemPrefab size: " + lzip.getEntrySize(ppath + "/testZip.zip", "dir1/dir2/test2.bmp").ToString());
plog();
@@ -340,7 +340,7 @@ public class testZip : MonoBehaviour
// File.WriteAllBytes(ppath + "/out.bmp", reusableBuffer2);
plog();
// extract an entry in a zip archive to a fixed size buffer
// extract an ItemPrefab in a zip archive to a fixed size buffer
plog("entry2FixedBuffer: " + lzip.entry2FixedBuffer(ppath + "/testZip.zip", "dir1/dir2/test2.bmp", ref fixedBuffer).ToString());
plog();
@@ -427,23 +427,23 @@ public class testZip : MonoBehaviour
Thread th = new Thread(decompressFunc); th.Start();
// delete/replace entry example
// delete/replace ItemPrefab example
if(File.Exists(ppath+"/test-Zip.zip")) File.Delete(ppath+"/test-Zip.zip");
if(File.Exists(ppath+"/testZip.zip")) File.Copy(ppath+"/testZip.zip", ppath+"/test-Zip.zip");
// replace an entry with a byte buffer
// replace an ItemPrefab with a byte buffer
var newBuffer3 = lzip.entry2Buffer(ppath + "/testZip.zip", "dir1/dir2/test2.bmp");
plog("replace entry: "+lzip.replace_entry(ppath+"/test-Zip.zip", "dir1/dir2/test2.bmp", newBuffer3, 9, null).ToString() );
plog("replace ItemPrefab: "+lzip.replace_entry(ppath+"/test-Zip.zip", "dir1/dir2/test2.bmp", newBuffer3, 9, null).ToString() );
// replace an entry with a file in the disk (ability to asign a password or bz2 compression)
plog("replace entry 2: "+lzip.replace_entry(ppath+"/test-Zip.zip", "dir1/dir2/test2.bmp",ppath+"/dir1/dir2/test2.bmp", 9, null, null).ToString() );
// replace an ItemPrefab with a file in the disk (ability to asign a password or bz2 compression)
plog("replace ItemPrefab 2: "+lzip.replace_entry(ppath+"/test-Zip.zip", "dir1/dir2/test2.bmp",ppath+"/dir1/dir2/test2.bmp", 9, null, null).ToString() );
// delete an entry in the zip
plog("delete entry: "+lzip.delete_entry(ppath+"/test-Zip.zip", "dir1/dir2/test2.bmp").ToString() );
// delete an ItemPrefab in the zip
plog("delete ItemPrefab: "+lzip.delete_entry(ppath+"/test-Zip.zip", "dir1/dir2/test2.bmp").ToString() );
}
@@ -570,14 +570,14 @@ public class testZip : MonoBehaviour
plog("total entries: " + lzip.getTotalEntries(null, fileBuffer) );
// entry exists
// ItemPrefab exists
bool eres = lzip.entryExists(null, "dir1/dir2/test2.bmp", fileBuffer);
plog("entry exists: " + eres.ToString());
plog("ItemPrefab exists: " + eres.ToString());
// extract an entry
// extract an ItemPrefab
zres = lzip.extract_entry(null, "dir1/dir2/test2.bmp", ppath + "/test22B.bmp", fileBuffer, progress2);
plog("extract entry: " + zres.ToString() + " progress: " + progress2[0]);
plog("extract ItemPrefab: " + zres.ToString() + " progress: " + progress2[0]);
plog();
// extract entries using a List
@@ -590,7 +590,7 @@ public class testZip : MonoBehaviour
// get the uncompressed size of a specific file in the zip archive
plog("get entry size: " + lzip.getEntrySize(null, "dir1/dir2/test2.bmp", fileBuffer).ToString());
plog("get ItemPrefab size: " + lzip.getEntrySize(null, "dir1/dir2/test2.bmp", fileBuffer).ToString());
plog();
@@ -692,13 +692,13 @@ public class testZip : MonoBehaviour
// a buffer to perform decompression operations from an in memory zip to it.
byte[] bf = null;
// a function that decompresses an entry from an in memory zip to a buffer that will get resized to fit the output.
// a function that decompresses an ItemPrefab from an in memory zip to a buffer that will get resized to fit the output.
plog("entry2BufferMem: " + lzip.entry2BufferMem(t,"inmem/test.bmp", ref bf, "1234").ToString());
// a function that decompresses an entry from an in memory zip to a fixed size buffer.
// a function that decompresses an ItemPrefab from an in memory zip to a fixed size buffer.
plog("entry2FixedBufferMem: " + lzip.entry2FixedBufferMem(t, "inmem/test.bmp", ref bf, "1234").ToString());
// a function that decompresses an entry from an in memory zip to a new created buffer and returns it.
// a function that decompresses an ItemPrefab from an in memory zip to a new created buffer and returns it.
var bt = lzip.entry2BufferMem(t, "inmem/test.bmp", "1234");
plog("entry2BufferMem new buffer: " + bt.Length.ToString());
@@ -721,10 +721,10 @@ public class testZip : MonoBehaviour
// Read some file to a byte[] buffer (as an example only).
reusableBuffer2a = File.ReadAllBytes(ppath + "/dir1/dir2/dir3/Unity_1.jpg");
// Add a buffer as a first entry in the inMemory zip
// Add a buffer as a first ItemPrefab in the inMemory zip
lzip.inMemoryZipAdd(t2, 9, reusableBuffer2a, "test.jpg");
// Add a second buffer as the second entry.
// Add a second buffer as the second ItemPrefab.
lzip.inMemoryZipAdd(t2, 9, reusableBuffer2, "directory/test.bmp");
// !!! -> After finishing adding buffer/files in the inMemory zip we must close it <- !!!
@@ -845,8 +845,8 @@ public class testZip : MonoBehaviour
plog("processed: " + tarProgress[0]);
plog();
plog("Extract Tar entry: " + lzip.tarExtractEntry(ppath + "/out.tar", "mergedTests/dir1/dir2/test2.bmp", ppath + "/tarOut2", true, tarProgress).ToString());
plog("Extract Tar entry absolute Path: " + lzip.tarExtractEntry(ppath + "/out.tar", "mergedTests/overriden.jpg", ppath + "/outTarAbsolute.jpeg", false, tarProgress).ToString());
plog("Extract Tar ItemPrefab: " + lzip.tarExtractEntry(ppath + "/out.tar", "mergedTests/dir1/dir2/test2.bmp", ppath + "/tarOut2", true, tarProgress).ToString());
plog("Extract Tar ItemPrefab absolute Path: " + lzip.tarExtractEntry(ppath + "/out.tar", "mergedTests/overriden.jpg", ppath + "/outTarAbsolute.jpeg", false, tarProgress).ToString());
plog();
plog("tar.gz creation: " + lzip.gzipFile( ppath + "/out.tar", ppath + "/out.tar.gz", 10).ToString());
@@ -889,7 +889,7 @@ public class testZip : MonoBehaviour
// if the merged file exists, perfom some operations with it.
}
// get entry info of the merged zip. (Can be used also for regular zip archives to get extended info on the entries. After calling this iterate through the lzip.zinfo List.)
// get ItemPrefab info of the merged zip. (Can be used also for regular zip archives to get extended info on the entries. After calling this iterate through the lzip.zinfo List.)
plog("Get Info of merged zip: " + lzip.getZipInfo(ppath + "/merged.jpg").ToString());
// if the zip has entries
@@ -906,8 +906,8 @@ public class testZip : MonoBehaviour
plog("Decompress to disk from merged file: " + lzip.decompressZipMerged(ppath + "/merged.jpg", ppath + "/mergedTests/", prog, byteProgress).ToString() + " progress: " + byteProgress[0].ToString());
// extract an entry from the merged zip that resides in the file system and override the entry name.
plog("Extract entry to disk from merged file: " + lzip.entry2FileMerged(ppath + "/merged.jpg", "dir1/dir2/dir3/Unity_1.jpg", ppath + "/mergedTests", "overriden.jpg"));
// extract an ItemPrefab from the merged zip that resides in the file system and override the ItemPrefab name.
plog("Extract ItemPrefab to disk from merged file: " + lzip.entry2FileMerged(ppath + "/merged.jpg", "dir1/dir2/dir3/Unity_1.jpg", ppath + "/mergedTests", "overriden.jpg"));
plog();
// now let's say we have the above archive in a memory buffer.
@@ -927,27 +927,27 @@ public class testZip : MonoBehaviour
// decompress to disk from a merged file that resides in a buffer.
plog("Decompress to disk from merged buffer: " + lzip.decompressZipMerged(tempBuffer, ppath + "/mergedTests/", prog).ToString());
// extract an entry from the merged zip in the buffer to disk.
// extract an ItemPrefab from the merged zip in the buffer to disk.
plog("Entry2File from merged buffer: " + lzip.entry2FileMerged( tempBuffer, "dir1/dir2/dir3/Unity_1.jpg", ppath + "/mergedTests").ToString());
plog();
// extract an entry from a merged file in the file system to a new buffer.
// extract an ItemPrefab from a merged file in the file system to a new buffer.
var newBuffer = lzip.entry2BufferMerged(ppath + "/merged.jpg", "dir1/dir2/dir3/Unity_1.jpg");
plog("Size of entry in new buffer 1: " + newBuffer.Length);
plog("Size of ItemPrefab in new buffer 1: " + newBuffer.Length);
newBuffer = null;
// extract an entry from a merged file in the file system to a fixed sized buffer.
// extract an ItemPrefab from a merged file in the file system to a fixed sized buffer.
byte[] fixedSizedBuffer = new byte[11 * 1024];
plog("Size of entry in fixed buffer 1: " + lzip.entry2FixedBufferMerged(ppath + "/merged.jpg", "dir1/dir2/dir3/Unity_1.jpg", ref fixedSizedBuffer).ToString());
plog("Size of ItemPrefab in fixed buffer 1: " + lzip.entry2FixedBufferMerged(ppath + "/merged.jpg", "dir1/dir2/dir3/Unity_1.jpg", ref fixedSizedBuffer).ToString());
plog();
// extract an entry from a merged file in a buffer to a new buffer.
// extract an ItemPrefab from a merged file in a buffer to a new buffer.
var newBuffer2 = lzip.entry2BufferMerged(tempBuffer, "dir1/dir2/dir3/Unity_1.jpg");
plog("Size of entry in new buffer 2: " + newBuffer2.Length);
plog("Size of ItemPrefab in new buffer 2: " + newBuffer2.Length);
// extract an entry from a merged file in a buffer to a fixed sized buffer.
plog("Size of entry in fixed buffer 2: " + lzip.entry2FixedBufferMerged(tempBuffer, "dir1/dir2/dir3/Unity_1.jpg", ref fixedSizedBuffer).ToString());
// extract an ItemPrefab from a merged file in a buffer to a fixed sized buffer.
plog("Size of ItemPrefab in fixed buffer 2: " + lzip.entry2FixedBufferMerged(tempBuffer, "dir1/dir2/dir3/Unity_1.jpg", ref fixedSizedBuffer).ToString());
fixedSizedBuffer = null;
tempBuffer = null;