/// Get the version of PhysicsFS that is linked against your program
/// </summary>
/// <returns>The version of PhysicsFS that is linked against your program</returns>
publicstaticVersionGetLinkedVersion()
{
Versionv=newVersion();
Interop.PHYSFS_getLinkedVersion(refv);
returnv;
}
/// <summary>
/// Initialize the PhysicsFS library.
/// </summary>
/// <remarks>
/// Must be called before any other PhysicsFS function.
/// This should be called prior to any attempts to change your process's current working directory.
/// </remarks>
/// <param name="argv0">This should be the path of the executable (first arguments passed to main function in C programs)</param>
publicstaticvoidInit(stringargv0)
{
interr=Interop.PHYSFS_init(argv0);
ThrowException(err);
}
/// <summary>
/// Deinitialize the PhysicsFS library.
/// </summary>
///
/// <para>
/// This closes any files opened via PhysicsFS, blanks the search/write paths, frees memory, and invalidates all of your file handles.
/// </para>
///
/// <remarks>
/// This call can throw if there's a file open for writing that refuses to close
/// (for example, the underlying operating system was buffering writes to network filesystem,
/// and the fileserver has crashed, or a hard drive has failed, etc). It is usually best to
/// close all write handles yourself before calling this function, so that you can gracefully handle a specific failure.
/// Once successfully deinitialized, Init can be called again to restart the subsystem.
/// All default API states are restored at this point, with the exception of any custom allocator you might have specified, which survives between initializations.
/// </remarks>
publicstaticvoidDeinit()
{
interr=Interop.PHYSFS_deinit();
ThrowException(err);
}
/// <summary>
/// Add an archive or directory to the search path.
/// </summary>
/// <para>
/// If this is a duplicate, the entry is not added again, even though the function succeeds.
/// You may not add the same archive to two different mountpoints: duplicate checking is done against the archive and not the mountpoint.
/// </para>
/// <para>
/// When you mount an archive, it is added to a virtual file system...all files in all of the archives are interpolated into a single hierachical file tree.
/// Two archives mounted at the same place (or an archive with files overlapping another mountpoint) may have overlapping files:
/// in such a case, the file earliest in the search path is selected, and the other files are inaccessible to the application.
/// This allows archives to be used to override previous revisions; you can use the mounting mechanism to place archives at a specific point
/// in the file tree and prevent overlap; this is useful for downloadable mods that might trample over application data or each other, for example.
/// </para>
/// <para>
/// The mountpoint does not need to exist prior to mounting, which is different than those familiar with the Unix concept of "mounting" may not expect.
/// As well, more than one archive can be mounted to the same mountpoint, or mountpoints and archive contents can overlap...the interpolation mechanism still functions as usual.
/// </para>
/// <param name="dir">directory or archive to add to the path, in platform-dependent notation.</param>
/// <param name="mountPoint">Location in the interpolated tree that this archive will be "mounted", in platform-independent notation. null or "" is equivalent to "/".</param>
/// <param name="appendToPath">True to append to search path, false to prepend.</param>
/// This may cause a significant amount of blocking while discs are accessed, and if there are no discs in the drive (or even not mounted on Unix systems),
/// then they may not be made available anyhow. You may want to specify false and handle the disc setup yourself.
/// <param name="archivesFirst">True to prepend the archives to the search path. False to append them. Ignored if !<paramref name="archiveExt"/>.</param>
/// <para>A directory must be empty before this call can delete it.</para>
/// <para>Deleting a symlink will remove the link, not what it points to, regardless of whether you "permitSymLinks" or not.</para>
/// <para>
/// So if you've got the write dir set to "C:\mygame\writedir" and call Delete("downloads/maps/level1.map")
/// then the file "C:\mygame\writedir\downloads\maps\level1.map" is removed from the physical filesystem,
/// if it exists and the operating system permits the deletion.
/// </para>
/// <para>
/// Note that on Unix systems, deleting a file may be successful,
/// but the actual file won't be removed until all processes that have an open filehandle to it (including your program) close their handles.
/// </para>
/// <para>
/// Chances are, the bits that make up the file still exist,
/// they are just made available to be written over at a later point.
/// Don't consider this a security method or anything. :)
/// </para>
/// <param name="filename">Filename to delete.</param>
publicstaticvoidDelete(stringfilename)
{
interr=Interop.PHYSFS_delete(filename);
ThrowException(err);
}
/// <summary>
/// Figure out where in the search path a file resides.
/// </summary>
/// <para>
/// The file is specified in platform-independent notation.
/// The returned filename will be the element of the search path where the file was found, which may be a directory, or an archive.
/// Even if there are multiple matches in different parts of the search path, only the first one found is used, just like when opening a file.
/// </para>
/// <para>
/// So, if you look for "maps/level1.map", and C:\mygame is in your search path and C:\mygame\maps\level1.map exists, then "C:\mygame" is returned.
/// </para>
/// <para>If a any part of a match is a symbolic link, and you've not explicitly permitted symlinks, then it will be ignored, and the search for a match will continue.</para>
/// <para>
/// If you specify a fake directory that only exists as a mount point, it'll be associated with the first archive mounted there,
/// even though that directory isn't necessarily contained in a real archive.
/// </para>
/// <param name="filename">File to look for.</param>
/// <returns>String of element of search path containing the the file in question. null if not found.</returns>
publicstaticstringGetRealDir(stringfilename)
{
returnInterop.PHYSFS_getRealDir(filename);
}
/// <summary>
/// Determine if a file exists in the search path.
/// </summary>
/// <para>Reports true if there is an entry anywhere in the search path by the name of <paramref name="fname"/>.</para>
/// <para>
/// Note that entries that are symlinks are ignored if PhysFS.PermitSymbolicLinks(true) hasn't been called,
/// so you might end up further down in the search path than expected.
/// </para>
/// <param name="fname">Filename in platform-independent notation.</param>
/// <returns>True if filename exists. false otherwise.</returns>
publicstaticboolExists(stringfname)
{
returnInterop.PHYSFS_exists(fname)!=0;
}
/// <summary>
/// Determine if a file in the search path is really a directory.
/// </summary>
/// <para>Determine if the first occurence of <paramref name="fname"/> in the search path is really a directory entry.</para>
/// <para>Note that entries that are symlinks are ignored if PhysFS.PermitSymbolicLinks(true) hasn't been called, so you might end up further down in the search path than expected.</para>
/// <param name="fname">Filename in platform-independent notation.</param>
/// <returns>True if filename exists and is a directory. False otherwise.</returns>
publicstaticboolIsDirectory(stringfname)
{
returnInterop.PHYSFS_isDirectory(fname)!=0;
}
/// <summary>
/// Determine if a file in the search path is really a symbolic link.
/// </summary>
/// <para>Determine if the first occurence of <paramref name="fname"/> in the search path is really a symbolic link.</para>
/// <para>Note that entries that are symlinks are ignored if PhysFS.PermitSymbolicLinks(true) hasn't been called, and as such, this function will always return false in that case.</para>
/// <param name="fname">Filename in platform-independent notation.</param>
/// <returns>True if filename exists and is a symlink. False otherwise.</returns>
publicstaticboolIsSymbolicLink(stringfname)
{
returnInterop.PHYSFS_isSymbolicLink(fname)!=0;
}
/// <summary>
/// Get the last modification time of a file.
/// </summary>
/// <para>
/// The modtime is returned as a number of seconds since the epoch (Jan 1, 1970).
/// The exact derivation and accuracy of this time depends on the particular archiver.
/// If there is no reasonable way to obtain this information for a particular archiver, or there was some sort of error, this function returns (-1).
/// </para>
/// <param name="fname">Filename to check, in platform-independent notation.</param>
/// <returns>Last modified time of the file. -1 if it can't be determined.</returns>
publicstaticlongGetLastModTime(stringfname)
{
returnInterop.PHYSFS_getLastModTime(fname);
}
/// <summary>
/// Determine if the PhysicsFS library is initialized.
/// </summary>
/// <para>
/// Once PhysFS.Init() returns successfully, this will return true.
/// Before a successful PhysFS.Init() and after PhysFS.Deinit() returns successfully, this will return false. This function is safe to call at any time.
/// </para>
/// <returns>True if library is initialized, false if library is not.</returns>
publicstaticboolIsInit()
{
returnInterop.PHYSFS_isInit()!=0;
}
/// <summary>
/// Determine if the symbolic links are permitted.
/// </summary>
/// <para>
/// This reports the setting from the last call to PhysFS.PermitSymbolicLinks().
/// If PhysFS.PermitSymbolicLinks() hasn't been called since the library was last initialized, symbolic links are implicitly disabled.
/// </para>
/// <returns>True if symlinks are permitted, false if not.</returns>
publicstaticboolSymbolicLinksPermitted()
{
returnInterop.PHYSFS_symbolicLinksPermitted()!=0;
}
publicstaticvoidSetAllocator(Allocatorallocator)
{
interr=Interop.PHYSFS_setAllocator(allocator);
ThrowException(err);
}
/// <summary>
/// Determine a mounted archive's mountpoint.
/// </summary>
/// <para>
/// You give this function the name of an archive or dir you successfully added to the search path, and it reports the location in the interpolated tree where it is mounted.
/// Files mounted with an empty mountpoint or through PhysFS.AddToSearchPath() will report "/".
/// </para>
/// <param name="dir">
/// Directory or archive previously added to the path, in platform-dependent notation.
/// This must match the string used when adding, even if your string would also reference the same file with a different string of characters.
/// </param>
/// <returns>String of mount point if added to path</returns>