From 48cb3c70ef3263bcd132a064bbfd27de0192504f Mon Sep 17 00:00:00 2001 From: "Gregory S. Read" <18175637+readgs@users.noreply.github.com> Date: Tue, 7 Jan 2003 23:35:10 +0000 Subject: [PATCH] -First version of PhysFS.NET. --- extras/PhysFS.NET/AssemblyInfo.cs | 58 +++++ extras/PhysFS.NET/PhysFS.NET.csproj | 113 +++++++++ extras/PhysFS.NET/PhysFS.NET.sln | 21 ++ extras/PhysFS.NET/PhysFS.cs | 189 ++++++++++++++ extras/PhysFS.NET/PhysFSFileStream.cs | 194 +++++++++++++++ extras/PhysFS.NET/PhysFS_DLL.cs | 113 +++++++++ extras/PhysFS.NET/README.txt | 10 + extras/PhysFS.NET/TestApp/App.ico | Bin 0 -> 1078 bytes extras/PhysFS.NET/TestApp/AssemblyInfo.cs | 58 +++++ extras/PhysFS.NET/TestApp/TestApp.csproj | 116 +++++++++ extras/PhysFS.NET/TestApp/TestApp.sln | 27 ++ extras/PhysFS.NET/TestApp/TestAppForm.cs | 274 +++++++++++++++++++++ extras/PhysFS.NET/TestApp/TestAppForm.resx | 102 ++++++++ 13 files changed, 1275 insertions(+) create mode 100755 extras/PhysFS.NET/AssemblyInfo.cs create mode 100755 extras/PhysFS.NET/PhysFS.NET.csproj create mode 100755 extras/PhysFS.NET/PhysFS.NET.sln create mode 100755 extras/PhysFS.NET/PhysFS.cs create mode 100755 extras/PhysFS.NET/PhysFSFileStream.cs create mode 100755 extras/PhysFS.NET/PhysFS_DLL.cs create mode 100755 extras/PhysFS.NET/README.txt create mode 100755 extras/PhysFS.NET/TestApp/App.ico create mode 100755 extras/PhysFS.NET/TestApp/AssemblyInfo.cs create mode 100755 extras/PhysFS.NET/TestApp/TestApp.csproj create mode 100755 extras/PhysFS.NET/TestApp/TestApp.sln create mode 100755 extras/PhysFS.NET/TestApp/TestAppForm.cs create mode 100755 extras/PhysFS.NET/TestApp/TestAppForm.resx diff --git a/extras/PhysFS.NET/AssemblyInfo.cs b/extras/PhysFS.NET/AssemblyInfo.cs new file mode 100755 index 00000000..67157c6f --- /dev/null +++ b/extras/PhysFS.NET/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("PhysFS.NET")] +[assembly: AssemblyDescription("PhysFS Bindings for .NET")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysFS.NET")] +[assembly: AssemblyCopyright("(c)2003 Gregory S. Read")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/extras/PhysFS.NET/PhysFS.NET.csproj b/extras/PhysFS.NET/PhysFS.NET.csproj new file mode 100755 index 00000000..3b827b89 --- /dev/null +++ b/extras/PhysFS.NET/PhysFS.NET.csproj @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extras/PhysFS.NET/PhysFS.NET.sln b/extras/PhysFS.NET/PhysFS.NET.sln new file mode 100755 index 00000000..341aa475 --- /dev/null +++ b/extras/PhysFS.NET/PhysFS.NET.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysFS.NET", "PhysFS.NET.csproj", "{C6205A43-3D4D-41E6-872C-96CD7BE55230}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Debug.ActiveCfg = Debug|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Debug.Build.0 = Debug|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Release.ActiveCfg = Release|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/extras/PhysFS.NET/PhysFS.cs b/extras/PhysFS.NET/PhysFS.cs new file mode 100755 index 00000000..30b7dace --- /dev/null +++ b/extras/PhysFS.NET/PhysFS.cs @@ -0,0 +1,189 @@ +/* PhysFS.cs - (c)2003 Gregory S. Read + * Provides access to PhysFS API calls not specific to file handle access. + */ +using System; + +namespace PhysFS_NET +{ + public class PhysFS + { + /* Initialize + * Inits the PhysFS API. This normally does not need to be called unless + * the API has been manually deinitialized since the PhysFS_DLL class + * initializes just before the first call is made into the DLL. + * Parameters + * none + * Returns + * none + * Exceptions + * PhysFSException - An error occured in the PhysFS API + */ + public static void Initialize() + { + // Initialize the physfs library, raise an exception if error + if(PhysFS_DLL.PHYSFS_init("") == 0) + throw new PhysFSException(); + } + + /* Deinitialize + * Deinits the PhysFS API. It is recommended that this method be called + * by the application before exiting in order to gracefully deallocate + * resources and close all filehandles, etc. + * Parameters + * none + * Returns + * none + * Exceptions + * PhysFSException - An error occured in the PhysFS API + */ + public static void Deinitialize() + { + // Deinit, raise an exception if an error occured + if(PhysFS_DLL.PHYSFS_deinit() == 0) + throw new PhysFSException(); + } + + /* BaseDir + * Gets the base directory configured for PhysFS. See the PhysFS API + * documentation for more information. + * Parameters + * none + * Returns + * A string value representing the Base Directory + * Exceptions + * none + */ + public static string BaseDir + { + get + { + // Return the current base directory + return PhysFS_DLL.PHYSFS_getBaseDir(); + } + } + + /* WriteDir + * Gets or sets the write directory configured for PhysFS. See the PhysFS API + * documentation for more information. + * Parameters + * set - Path to set the WriteDir property to + * Returns + * A string value representing the Write Directory + * Exceptions + * PhysFSException - An error occured in the PhysFS API when + * settings the write directory. + */ + public static string WriteDir + { + get + { + // Return the current write directory + return PhysFS_DLL.PHYSFS_getWriteDir(); + } + set + { + // Set the write directory and raise an exception if an error occured + if(PhysFS_DLL.PHYSFS_setWriteDir(value) == 0) + throw new PhysFSException(); + } + } + + /* UserDir + * Gets or sets the write directory configured for PhysFS. See the PhysFS API + * documentation for more information. + * Parameters + * set - Path to set the WriteDir property to + * Returns + * A string value representing the Write Directory + * Exceptions + * PhysFSException - An error occured in the PhysFS API when + * settings the write directory. + */ + public static string UserDir + { + get + { + // Return the current user directory + return PhysFS_DLL.PHYSFS_getUserDir(); + } + } + public static void AddToSearchPath(string NewDir, bool Append) + { + if(PhysFS_DLL.PHYSFS_addToSearchPath(NewDir, Append?1:0) == 0) + throw new PhysFSException(); + } + public static void RemoveFromSearchPath(string OldDir) + { + if(PhysFS_DLL.PHYSFS_removeFromSearchPath(OldDir) == 0) + throw new PhysFSException(); + } + public unsafe static string[] GetSearchPath() + { + byte** p; // Searchpath list from PhysFS dll + string[] pathlist; // List converted to an array + + // Get the CDROM drive listing + p = PhysFS_DLL.PHYSFS_getSearchPath(); + // Convert the C-style array to a .NET style array + pathlist = PhysFS_DLL.BytePPToArray(p); + // Free the original list since we're done with it + PhysFS_DLL.PHYSFS_freeList(p); + + return pathlist; + } + public unsafe static string[] GetCDROMDrives() + { + byte** p; // CDROM list from PhysFS dll + string[] cdromlist; // List converted to an array + + // Get the CDROM drive listing + p = PhysFS_DLL.PHYSFS_getCdRomDirs(); + // Convert the C-style array to a .NET style array + cdromlist = PhysFS_DLL.BytePPToArray(p); + // Free the original list since we're done with it + PhysFS_DLL.PHYSFS_freeList(p); + + return cdromlist; + } + public static void MkDir(string Dirname) + { + if(PhysFS_DLL.PHYSFS_mkdir(Dirname) == 0) + throw new PhysFSException(); + } + public static void Delete(string Filename) + { + if(PhysFS_DLL.PHYSFS_delete(Filename) == 0) + throw new PhysFSException(); + } + public static string GetRealDir(string Filename) + { + string RetValue; + + RetValue = PhysFS_DLL.PHYSFS_getRealDir(Filename); + if(RetValue == null) + throw new PhysFSException("File not found in search path."); + + // Return the real file path of the specified filename + return RetValue; + } + public unsafe static string[] EnumerateFiles(string Dirname) + { + byte** p; // File list from PhysFS dll + string[] filelist; // List converted to an array + + // Get the CDROM drive listing + p = PhysFS_DLL.PHYSFS_enumerateFiles(Dirname); + // Convert the C-style array to a .NET style array + filelist = PhysFS_DLL.BytePPToArray(p); + // Free the original list since we're done with it + PhysFS_DLL.PHYSFS_freeList(p); + + return filelist; + } + public static bool IsDirectory(string Filename) + { + // Return true if non-zero, otherwise return false + return (PhysFS_DLL.PHYSFS_isDirectory(Filename) == 0)?false:true; + } + } +} diff --git a/extras/PhysFS.NET/PhysFSFileStream.cs b/extras/PhysFS.NET/PhysFSFileStream.cs new file mode 100755 index 00000000..c0f6b051 --- /dev/null +++ b/extras/PhysFS.NET/PhysFSFileStream.cs @@ -0,0 +1,194 @@ +/* PhysFSFileStream.cs - (c)2003 Gregory S. Read */ +using System; +using System.Collections; +using System.IO; + +namespace PhysFS_NET +{ + public enum PhysFSFileMode {Read, Write, Append}; + + // Our exception class we'll use for throwing all PhysFS API related exception + public class PhysFSException : IOException + { + public PhysFSException(string Message) : base(Message) {} + public PhysFSException() : base(PhysFS_DLL.PHYSFS_getLastError()) {} + } + + public unsafe class PhysFSFileStream : Stream + { + // ***Public properties*** + public override bool CanRead + { + get + { + // Reading is supported + return true; + } + } + + public override bool CanSeek + { + get + { + // Seek is supported + return true; + } + } + + public override bool CanWrite + { + get + { + // Writing is supported + return true; + } + } + + public override long Length + { + get + { + long TempLength; + TempLength = PhysFS_DLL.PHYSFS_fileLength(pHandle); + + // If call returned an error, throw an exception + if(TempLength == -1) + throw new PhysFSException(); + + return TempLength; + } + } + + public override long Position + { + get + { + long TempPosition; + TempPosition = PhysFS_DLL.PHYSFS_tell(pHandle); + + // If call returned an error, throw an exception + if(TempPosition == -1) + throw new PhysFSException(); + + return TempPosition; + } + set + { + // Seek from beginning of file using the position value + Seek(value, SeekOrigin.Begin); + } + } + + // ***Public methods*** + public PhysFSFileStream(string FileName, PhysFSFileMode FileMode, ulong BufferSize) + { + // Open the specified file with the appropriate file access + switch(FileMode) + { + case PhysFSFileMode.Read: + pHandle = PhysFS_DLL.PHYSFS_openRead(FileName); + break; + case PhysFSFileMode.Write: + pHandle = PhysFS_DLL.PHYSFS_openWrite(FileName); + break; + case PhysFSFileMode.Append: + pHandle = PhysFS_DLL.PHYSFS_openAppend(FileName); + break; + default: + throw new PhysFSException("Invalid FileMode specified"); + } + + // If handle is null, an error occured, so raise an exception + //!!! Does object get created if exception is thrown? + if(pHandle == null) + throw new PhysFSException(); + + // Set buffer size, raise an exception if an error occured + if(PhysFS_DLL.PHYSFS_setBuffer(pHandle, BufferSize) == 0) + throw new PhysFSException(); + } + + // This constructor sets the buffer size to 0 if not specified + public PhysFSFileStream(string FileName, PhysFSFileMode FileMode) : this(FileName, FileMode, 0) {} + + ~PhysFSFileStream() + { + // Don't close the handle if they've specifically closed it already + if(!Closed) + Close(); + } + + public override void Flush() + { + if(PhysFS_DLL.PHYSFS_flush(pHandle) == 0) + throw new PhysFSException(); + } + + public override int Read(byte[] buffer, int offset, int count) + { + long RetValue; + + fixed(byte *pbytes = &buffer[offset]) + { + // Read into our allocated pointer + RetValue = PhysFS_DLL.PHYSFS_read(pHandle, pbytes, sizeof(byte), (uint)count); + } + + if(RetValue == -1) + throw new PhysFSException(); + + // Return number of bytes read + // Note: This cast should be safe since we are only reading 'count' items, which + // is of type 'int'. + return (int)RetValue; + } + + public override void Write(byte[] buffer, int offset, int count) + { + long RetValue; + + fixed(byte* pbytes = &buffer[offset]) + { + // Write buffer + RetValue = PhysFS_DLL.PHYSFS_write(pHandle, pbytes, sizeof(byte), (uint)count); + } + + if(RetValue == -1) + throw new PhysFSException(); + } + + public override long Seek(long offset, SeekOrigin origin) + { + // Only seeking from beginning is supported by PhysFS API + if(origin != SeekOrigin.Begin) + throw new PhysFSException("Only seek origin of \"Begin\" is supported"); + + // Seek to specified offset, raise an exception if error occured + if(PhysFS_DLL.PHYSFS_seek(pHandle, (ulong)offset) == 0) + throw new PhysFSException(); + + // Since we always seek from beginning, the offset is always + // the absolute position. + return offset; + } + + public override void SetLength(long value) + { + throw new NotSupportedException("SetLength method not supported in PhysFSFileStream objects."); + } + + public override void Close() + { + // Close the handle + if(PhysFS_DLL.PHYSFS_close(pHandle) == 0) + throw new PhysFSException(); + + // File has been closed. Rock. + Closed = true; + } + + // ***Private variables*** + private void *pHandle; + private bool Closed = false; + } +} \ No newline at end of file diff --git a/extras/PhysFS.NET/PhysFS_DLL.cs b/extras/PhysFS.NET/PhysFS_DLL.cs new file mode 100755 index 00000000..bc9300c0 --- /dev/null +++ b/extras/PhysFS.NET/PhysFS_DLL.cs @@ -0,0 +1,113 @@ +/* PhysFS_DLL - (c)2003 Gregory S. Read + * Internal class that provides direct access to the PhysFS DLL. It is + * not accessible outside of the PhysFS.NET assembly. + */ +using System.Collections; +using System.Runtime.InteropServices; + +namespace PhysFS_NET +{ + internal class PhysFS_DLL + { + /* Static constructor + * Initializes the PhysFS API before any method is called in this class. This + * relieves the user from having to explicitly initialize the API. + * Parameters + * none + * Returns + * none + * Exceptions + * PhysFSException - An error occured in the PhysFS API + */ + static PhysFS_DLL() + { + if(PHYSFS_init("") == 0) + throw new PhysFSException(); + } + + /* BytePPToArray + * Converts a C-style string array into a .NET managed string array + * Parameters + * C-style string array pointer returned from PhysFS + * Returns + * .NET managed string array + * Exceptions + * none + */ + public unsafe static string[] BytePPToArray(byte **bytearray) + { + byte** ptr; + byte* c; + string tempstr; + ArrayList MyArrayList = new ArrayList(); + string[] RetArray; + + for(ptr = bytearray; *ptr != null; ptr++) + { + tempstr = ""; + for(c = *ptr; *c != 0; c++) + { + tempstr += (char)*c; + } + + // Add string to our list + MyArrayList.Add(tempstr); + } + + // Return a normal array of the list + RetArray = new string[MyArrayList.Count]; + MyArrayList.CopyTo(RetArray, 0); + return RetArray; + } + + // Name of DLL to import + private const string PHYSFS_DLLNAME = "physfs.dll"; + + // DLL import declarations + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_init(string argv0); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_deinit(); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void PHYSFS_freeList(void *listVar); + [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getLastError(); + [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getDirSeparator(); + [DllImport(PHYSFS_DLLNAME)] public static extern void PHYSFS_permitSymbolicLinks(int allow); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe byte** PHYSFS_getCdRomDirs(); + [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getBaseDir(); + [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getUserDir(); + [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getWriteDir(); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_setWriteDir(string newDir); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_addToSearchPath(string newDir, int appendToPath); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_removeFromSearchPath(string oldDir); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe byte** PHYSFS_getSearchPath(); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_setSaneConfig(string organization, + string appName, + string archiveExt, + int includeCdRoms, + int archivesFirst); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_mkdir(string dirName); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_delete(string filename); + [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getRealDir(string filename); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe byte** PHYSFS_enumerateFiles(string dir); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_exists(string fname); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_isDirectory(string fname); + [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_isSymbolicLink(string fname); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void* PHYSFS_openWrite(string filename); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void* PHYSFS_openAppend(string filename); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void* PHYSFS_openRead(string filename); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_close(void* handle); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_getLastModTime(string filename); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_read(void* handle, + void *buffer, + uint objSize, + uint objCount); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_write(void* handle, + void *buffer, + uint objSize, + uint objCount); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_eof(void* handle); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_tell(void* handle); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_seek(void* handle, ulong pos); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_fileLength(void* handle); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_setBuffer(void* handle, ulong bufsize); + [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_flush(void* handle); + } +} diff --git a/extras/PhysFS.NET/README.txt b/extras/PhysFS.NET/README.txt new file mode 100755 index 00000000..62ecf633 --- /dev/null +++ b/extras/PhysFS.NET/README.txt @@ -0,0 +1,10 @@ +PhysFS.NET is a library that encapsulates the PhysFS API into a .NET assembly. + +There are two class objects that are exposed in the assembly: + PhysFS.cs + This class exposes any non-filehandle specific functionality contained in + the PhysFS library. + PhysFSFileStream.cs + A System.IO.Stream derived class which provides file access via the + PhysFS API. Usage of this object is identical to a standard stream + object. \ No newline at end of file diff --git a/extras/PhysFS.NET/TestApp/App.ico b/extras/PhysFS.NET/TestApp/App.ico new file mode 100755 index 0000000000000000000000000000000000000000..3a5525fd794f7a7c5c8e6187f470ea3af38cd2b6 GIT binary patch literal 1078 zcmeHHJr05}7=1t!Hp3A*8IHkVf+j?-!eHY14Gtcw1Eb*_9>Bq^zETJ@GKj{_2j4$w zo9}xCh!8{T3=X##Skq>ikMjsvB|y%crWBM2iW(4pI}c%z6%lW!=~4v77#3{z!dmB1 z__&l)-{KUYR+|8|;wB^R|9ET$J@(@=#rd^=)qs85?vAy(PSF5CyNkus435LVkZ$rj zNw|JG-P7^hF<(;#o*Vk}5R#e|^13tBbQkeF?djULtvqyxd3<{9 literal 0 HcmV?d00001 diff --git a/extras/PhysFS.NET/TestApp/AssemblyInfo.cs b/extras/PhysFS.NET/TestApp/AssemblyInfo.cs new file mode 100755 index 00000000..177a4f0e --- /dev/null +++ b/extras/PhysFS.NET/TestApp/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/extras/PhysFS.NET/TestApp/TestApp.csproj b/extras/PhysFS.NET/TestApp/TestApp.csproj new file mode 100755 index 00000000..e576a21f --- /dev/null +++ b/extras/PhysFS.NET/TestApp/TestApp.csproj @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extras/PhysFS.NET/TestApp/TestApp.sln b/extras/PhysFS.NET/TestApp/TestApp.sln new file mode 100755 index 00000000..d3390898 --- /dev/null +++ b/extras/PhysFS.NET/TestApp/TestApp.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp.csproj", "{9C1ECC6B-16C7-42B3-BF7C-8BA8D81BA980}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysFS.NET", "..\PhysFS.NET.csproj", "{C6205A43-3D4D-41E6-872C-96CD7BE55230}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {9C1ECC6B-16C7-42B3-BF7C-8BA8D81BA980}.Debug.ActiveCfg = Debug|.NET + {9C1ECC6B-16C7-42B3-BF7C-8BA8D81BA980}.Debug.Build.0 = Debug|.NET + {9C1ECC6B-16C7-42B3-BF7C-8BA8D81BA980}.Release.ActiveCfg = Release|.NET + {9C1ECC6B-16C7-42B3-BF7C-8BA8D81BA980}.Release.Build.0 = Release|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Debug.ActiveCfg = Debug|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Debug.Build.0 = Debug|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Release.ActiveCfg = Release|.NET + {C6205A43-3D4D-41E6-872C-96CD7BE55230}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/extras/PhysFS.NET/TestApp/TestAppForm.cs b/extras/PhysFS.NET/TestApp/TestAppForm.cs new file mode 100755 index 00000000..b897ae61 --- /dev/null +++ b/extras/PhysFS.NET/TestApp/TestAppForm.cs @@ -0,0 +1,274 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.IO; +using PhysFS_NET; + +namespace TestApp +{ + /// + /// Summary description for Form1. + /// + public class TestAppForm : System.Windows.Forms.Form + { + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button RefreshCDsButton; + private System.Windows.Forms.ListBox CDDrivesList; + private System.Windows.Forms.ListBox SearchPathList; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox EnumFilesPath; + private System.Windows.Forms.ListBox EnumList; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox NewSearchPathText; + private System.Windows.Forms.Button AddSearchPathButton; + private System.Windows.Forms.Button RemovePathButton; + private System.Windows.Forms.Button RefreshEnumList; + private System.Windows.Forms.Button RefreshSearchPathButton; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public TestAppForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label2 = new System.Windows.Forms.Label(); + this.RefreshCDsButton = new System.Windows.Forms.Button(); + this.CDDrivesList = new System.Windows.Forms.ListBox(); + this.SearchPathList = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.EnumFilesPath = new System.Windows.Forms.TextBox(); + this.EnumList = new System.Windows.Forms.ListBox(); + this.label3 = new System.Windows.Forms.Label(); + this.RefreshEnumList = new System.Windows.Forms.Button(); + this.NewSearchPathText = new System.Windows.Forms.TextBox(); + this.AddSearchPathButton = new System.Windows.Forms.Button(); + this.RemovePathButton = new System.Windows.Forms.Button(); + this.RefreshSearchPathButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label2 + // + this.label2.Location = new System.Drawing.Point(8, 8); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(136, 16); + this.label2.TabIndex = 2; + this.label2.Text = "Available CD-ROM Drives"; + // + // RefreshCDsButton + // + this.RefreshCDsButton.Location = new System.Drawing.Point(8, 152); + this.RefreshCDsButton.Name = "RefreshCDsButton"; + this.RefreshCDsButton.Size = new System.Drawing.Size(72, 24); + this.RefreshCDsButton.TabIndex = 4; + this.RefreshCDsButton.Text = "Refresh"; + this.RefreshCDsButton.Click += new System.EventHandler(this.RefreshCDsButton_Click); + // + // CDDrivesList + // + this.CDDrivesList.Location = new System.Drawing.Point(8, 24); + this.CDDrivesList.Name = "CDDrivesList"; + this.CDDrivesList.Size = new System.Drawing.Size(136, 121); + this.CDDrivesList.TabIndex = 7; + // + // SearchPathList + // + this.SearchPathList.Location = new System.Drawing.Point(152, 24); + this.SearchPathList.Name = "SearchPathList"; + this.SearchPathList.Size = new System.Drawing.Size(248, 95); + this.SearchPathList.TabIndex = 8; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(152, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(136, 16); + this.label1.TabIndex = 10; + this.label1.Text = "Search Path"; + // + // EnumFilesPath + // + this.EnumFilesPath.Location = new System.Drawing.Point(408, 128); + this.EnumFilesPath.Name = "EnumFilesPath"; + this.EnumFilesPath.Size = new System.Drawing.Size(208, 20); + this.EnumFilesPath.TabIndex = 11; + this.EnumFilesPath.Text = ""; + // + // EnumList + // + this.EnumList.Location = new System.Drawing.Point(408, 24); + this.EnumList.Name = "EnumList"; + this.EnumList.Size = new System.Drawing.Size(208, 95); + this.EnumList.TabIndex = 12; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(408, 8); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(136, 16); + this.label3.TabIndex = 13; + this.label3.Text = "Enumerate Files"; + // + // RefreshEnumList + // + this.RefreshEnumList.Location = new System.Drawing.Point(544, 152); + this.RefreshEnumList.Name = "RefreshEnumList"; + this.RefreshEnumList.Size = new System.Drawing.Size(72, 24); + this.RefreshEnumList.TabIndex = 14; + this.RefreshEnumList.Text = "Refresh"; + this.RefreshEnumList.Click += new System.EventHandler(this.RefreshEnumList_Click); + // + // NewSearchPathText + // + this.NewSearchPathText.Location = new System.Drawing.Point(152, 128); + this.NewSearchPathText.Name = "NewSearchPathText"; + this.NewSearchPathText.Size = new System.Drawing.Size(248, 20); + this.NewSearchPathText.TabIndex = 15; + this.NewSearchPathText.Text = ""; + // + // AddSearchPathButton + // + this.AddSearchPathButton.Location = new System.Drawing.Point(152, 152); + this.AddSearchPathButton.Name = "AddSearchPathButton"; + this.AddSearchPathButton.Size = new System.Drawing.Size(72, 24); + this.AddSearchPathButton.TabIndex = 9; + this.AddSearchPathButton.Text = "Add Path"; + this.AddSearchPathButton.Click += new System.EventHandler(this.AddSearchPathButton_Click); + // + // RemovePathButton + // + this.RemovePathButton.Location = new System.Drawing.Point(232, 152); + this.RemovePathButton.Name = "RemovePathButton"; + this.RemovePathButton.Size = new System.Drawing.Size(88, 24); + this.RemovePathButton.TabIndex = 16; + this.RemovePathButton.Text = "Remove Path"; + this.RemovePathButton.Click += new System.EventHandler(this.RemovePathButton_Click); + // + // RefreshSearchPathButton + // + this.RefreshSearchPathButton.Location = new System.Drawing.Point(328, 152); + this.RefreshSearchPathButton.Name = "RefreshSearchPathButton"; + this.RefreshSearchPathButton.Size = new System.Drawing.Size(72, 24); + this.RefreshSearchPathButton.TabIndex = 17; + this.RefreshSearchPathButton.Text = "Refresh"; + this.RefreshSearchPathButton.Click += new System.EventHandler(this.RefreshSearchPathButton_Click); + // + // TestAppForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(624, 309); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.RefreshSearchPathButton, + this.RemovePathButton, + this.NewSearchPathText, + this.RefreshEnumList, + this.label3, + this.EnumList, + this.EnumFilesPath, + this.label1, + this.SearchPathList, + this.CDDrivesList, + this.RefreshCDsButton, + this.label2, + this.AddSearchPathButton}); + this.Name = "TestAppForm"; + this.Text = "PhysFS Test Application"; + this.Load += new System.EventHandler(this.TestAppForm_Load); + this.ResumeLayout(false); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new TestAppForm()); + } + + private void TestAppForm_Load(object sender, System.EventArgs e) + { + + } + + private void RefreshCDsButton_Click(object sender, System.EventArgs e) + { + // Clear ths listbox if it contains any items + CDDrivesList.Items.Clear(); + // Add the items to the list + CDDrivesList.Items.AddRange(PhysFS.GetCDROMDrives()); + } + + private void RefreshSearchPathButton_Click(object sender, System.EventArgs e) + { + // Clear ths listbox if it contains any items + SearchPathList.Items.Clear(); + // Add the items to the list + SearchPathList.Items.AddRange(PhysFS.GetSearchPath()); + } + + private void AddSearchPathButton_Click(object sender, System.EventArgs e) + { + // Add search path + PhysFS.AddToSearchPath(NewSearchPathText.Text, false); + // Clear ths listbox if it contains any items + SearchPathList.Items.Clear(); + // Add the items to the list + SearchPathList.Items.AddRange(PhysFS.GetSearchPath()); + } + + private void RemovePathButton_Click(object sender, System.EventArgs e) + { + if(SearchPathList.SelectedItem != null) + { + PhysFS.RemoveFromSearchPath(SearchPathList.SelectedItem.ToString()); + // Clear ths listbox if it contains any items + SearchPathList.Items.Clear(); + // Add the items to the list + SearchPathList.Items.AddRange(PhysFS.GetSearchPath()); + } + } + + private void RefreshEnumList_Click(object sender, System.EventArgs e) + { + EnumList.Items.Clear(); + EnumList.Items.AddRange(PhysFS.EnumerateFiles(EnumFilesPath.Text)); + } + } +} diff --git a/extras/PhysFS.NET/TestApp/TestAppForm.resx b/extras/PhysFS.NET/TestApp/TestAppForm.resx new file mode 100755 index 00000000..26e9d797 --- /dev/null +++ b/extras/PhysFS.NET/TestApp/TestAppForm.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TestAppForm + + \ No newline at end of file