home *** CD-ROM | disk | FTP | other *** search
- /*____________________________________________________________________________*\
- *
-
- Copyright (c) 1997 John Roy. All rights reserved.
-
- These sources, libraries and applications are
- FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
- as long as the following conditions are adhered to.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- 3. Redistributions of any form whatsoever and all advertising materials
- mentioning features must contain the following
- acknowledgment:
- "This product includes software developed by John Roy
- (http://www.johnroy.com/pi3/)."
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- OF THE POSSIBILITY OF SUCH DAMAGE.
-
- *____________________________________________________________________________*|
- *
- * $Source: PIFInfo.h$
- * $Date: Sun Aug 10 06:29:35 1997$
- *
- Description:
- \*____________________________________________________________________________*/
- /* $HeaderTop:$ */
-
- #ifndef PIFINFO_H_
- #define PIFINFO_H_
-
- #include "PiAPI.h"
-
- /*____________________________________________________________________________*\
- *
- Typedefs:
- \*____________________________________________________________________________*/
- typedef struct FileSystemEntity PIFInfo;
- #define PIPLATFORM_FSIZE unsigned long
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_new
-
- Synopsis:
- PIFInfo *PIFInfo_new( const char *pPath )
-
- Description:
- Create a new file information object.
-
- Notes:
- This object should be deleted with PIFInfo_delete() when it is
- no longer needed.
-
- Return Values:
- On success PIFInfo_new() return a pointer to a new PIFInfo object.
-
- Errors:
- NULL will be returned if an pPath is NULL or memory could not be
- allocated for the new PIFInfo object.
-
- More specific error information can be retrieved using
- PIPlatform_getLastError().
-
- See Also:
- PIFInfo_delete().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIFInfo *PIFInfo_new( const char *pPath );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_delete
-
- Synopsis:
- int PIFInfo_delete( PIFInfo *pFileInfo );
-
- Description:
- Destroys an PIFInfo object and free any memory associated with it.
-
- Notes:
- Using pFileInfo for any further operations after PIFInfo_delete()
- has been used will cause undefined behaviour.
-
- Return Values:
- On success PIFInfo_delete() returns zero (PIAPI_COMPLETED).
-
- Errors:
- On error PIFInfo_delete() will return a non-zero value. The function
- PIPlatform_getLastError() can be used to retreve more specific error
- information.
-
- See Also:
- PIFInfo_new().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_delete( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_exists
-
- Synopsis:
- int PIFInfo_exists( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a file that actually exists.
-
- Notes:
- Always compare this return code against PIAPI_TRUE as some
- error return value may be non-negative.
-
- Return Values:
- On success PIFInfo_exists() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo exists.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_isRegular(), PIFInfo_isReadable(),
- PIFInfo_isDirectory(), PIFInfo_isLink().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_exists( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getName
-
- Synopsis:
- const char *PIFInfo_getName( PIFInfo *pFileInfo )
-
- Description:
- Returns the name of the file referred to by pFileInfo.
-
- Notes:
- Return Values:
- On sucess PIFInfo_getName() returns a non-NULL pointer to
- the filename.
-
- Errors:
- On error PIFInfo_getName() returns NULL. The function
- PIPlatform_getLastError() can be used to retrieve more specific
- error information.
-
- See Also:
- PIFInfo_getPath()
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI const char *PIFInfo_getName( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getAlternateName
-
- Synopsis:
- const char *PIFInfo_getAlternateName( PIFInfo *pFileInfo )
-
- Description:
- Returns the alternet name of the file referred to by pFileInfo.
-
- Notes:
- Some operating systems maintain alternate filenames for files. This function can be used to access the alternate filename. When the
- operating system does not define an alternate file
- PIFInfo_getAlternateName() behaves as PIFInfo_getName().
-
- Return Values:
- On sucess PIFInfo_getAlternateName() returns a non-NULL pointer to
- the alternate filename.
-
- Errors:
- On error PIFInfo_getAlternateName() returns NULL. The function
- PIPlatform_getLastError() can be used to retrieve more specific
- error information.
-
- See Also:
- PIFInfo_getPath()
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI const char *PIFInfo_getAlternateName( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getPath
-
- Synopsis:
- const char *PIFInfo_getPath( PIFInfo *pFileInfo )
-
- Description:
- Returns the full path to the file referred to by pFileInfo.
-
- Notes:
- Return Values:
- On sucess PIFInfo_getPath() returns a non-NULL pointer to
- the files path.
-
- Errors:
- On error PIFInfo_getPath() returns NULL. The function
- PIPlatform_getLastError() can be used to retrieve more specific
- error information.
-
- See Also:
- PIFInfo_getName()
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI const char *PIFInfo_getPath( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getPathRoot
-
- Synopsis:
- const char *PIFInfo_getPathRoot( PIFInfo *pFileInfo )
-
- Description:
- Returns the file path to the directory containing the file
- referred to by pFileInfo.
-
- Notes:
- Return Values:
- On sucess PIFInfo_getPathRoot() returns a non-NULL pointer.
-
- Errors:
- On error PIFInfo_getPathRoot() returns NULL. The function
- PIPlatform_getLastError() can be used to retrieve more specific
- error information.
-
- See Also:
- PIFInfo_getPathRoot()
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI const char *PIFInfo_getPathRoot( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_isRegular
-
- Synopsis:
- int PIFInfo_isRegular( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a file that is a regular file.
-
- Notes:
- Directories and symbolic links are some of the valid PIFInfo
- objects that are not regular files.
-
- Return Values:
- On success PIFInfo_isRegular() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo is a regular file.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_exists(), PIFInfo_isReadable(),
- PIFInfo_isDirectory(), PIFInfo_isLink().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_isRegular( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_isDirectory
-
- Synopsis:
- int PIFInfo_isDirectory( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a directory.
-
- Notes:
-
- Return Values:
- On success PIFInfo_isDirectory() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo is a directory.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_exists(), PIFInfo_isRegular(), PIFInfo_isReadable(),
- PIFInfo_isLink().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_isDirectory( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_isLink
-
- Synopsis:
- int PIFInfo_isLink( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a symbolic link.
-
- Notes:
-
- Return Values:
- On success PIFInfo_isLink() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo is a symbolic link.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_exists(), PIFInfo_isRegular(), PIFInfo_isReadable(),
- PIFInfo_isDirectory().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_isLink( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_isReadable
-
- Synopsis:
- int PIFInfo_isReadable( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a file that may be opened for reading.
-
- Notes:
- The readibility of a file is effected by its permissions, the
- user privilages of the executing program and the exclusive lock
- status of the file.
-
- Return Values:
- On success PIFInfo_isReadable() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo may be opened for reading.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_exists(), PIFInfo_isRegular(), PIFInfo_isExecutable(),
- PIFInfo_isWritable(), PIFInfo_isDirectory(), PIFInfo_isLink().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_isReadable( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_isWritable
-
- Synopsis:
- int PIFInfo_isWritable( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a file that may be opened for writting.
-
- Notes:
- The readibility of a file is effected by its permissions, the
- user privilages of the executing program and the types of locks
- held on the file.
-
- Return Values:
- On success PIFInfo_isWritable() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo may be opened for writting.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_exists(), PIFInfo_isRegular(), PIFInfo_isReadable(),
- PIFInfo_isExecutable(), PIFInfo_isDirectory(), PIFInfo_isLink().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_isWritable( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_isExecutable
-
- Synopsis:
- int PIFInfo_isExecutable( PIFInfo *pFileInfo )
-
- Description:
- Specifies whether or not the file information object pFileInfo
- refers to a file that may be executed as a program.
-
- Notes:
- The execute status of a file is effected by its permissions, the
- user privilages of the executing program and the exclusive lock
- status of the file.
-
- Return Values:
- On success PIFInfo_isExecutable() returns either PIAPI_TRUE or
- PIAPI_FALSE, indicating whether or not a file respresented by
- pFileInfo may be executed.
-
- Errors:
- This function does not generate an error.
-
- See Also:
- PIFInfo_exists(), PIFInfo_isRegular(), PIFInfo_isReadable(),
- PIFInfo_isWritable(), PIFInfo_isDirectory(), PIFInfo_isLink().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_isExecutable( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getSize
-
- Synopsis:
- PIPLATFORM_FSIZE PIFInfo_getFile( PIFInfo *pFileInfo )
-
- Description:
- Specifies the size of the file represented by file information
- object pFileInfo.
-
- Notes:
- PIPlatform_getLastError() must be used to distinguish an error
- condition from a zero length file.
-
- Return Values:
- On success PIFInfo_getFile() returns the file size. On failure
- PIFInfo_getFile() returns 0.
-
- Errors:
- PIPlatform_getLastError() can be examined to distinguish an error
- condition from a zero byte file. PIFInfo_getSize() will set the
- thread specific error code to PIAPI_COMPLETED before attempting to
- get the file size. If PIPlatform_getLastError() returns 0
- (PIAPI_COMPLETED) then no error occured. See 'Errors' for a full
- description of possible errors.
-
- See Also:
- PIFInfo_getExtension().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIPLATFORM_FSIZE PIFInfo_getSize( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getLastModified
-
- Synopsis:
- PIPLATFORM_TIME PIFInfo_getLastModified( PIFInfo *pFileInfo )
-
- Description:
- Gives the time of the last modification to the file specified
- by pFileInfo.
-
- Notes:
- Time is measured in seconds elapsed since 00:00:00 UTC, Jan. 1, 1970.
-
- Return Values:
- On success PIFInfo_getFile() returns the time of the last modification
- to the file pFileInfo. On error PIFInfo_getLastModified() returns 0.
-
- Errors:
- PIPlatform_getLastError() can be examined to distinguish an error
- condition from a file which was last modified at exactly
- 00:00:00 UTC, Jan. 1, 1970.
-
- See Also:
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIPLATFORM_TIME PIFInfo_getLastModified( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getExtension
-
- Synopsis:
- const char *PIFInfo_getExtension( PIFInfo *pFileInfo )
-
- Description:
- Returns the extension of the file represented by pFileInfo.
- A file extension is the sequence of characters following the
- last period ('.') in the filename, when scanning left to right.
-
- Notes:
- PIFInfo_getExtension() may operate correctly even when pFileInfo
- does not represent a real file.
-
- The returned value is a pointer to a component of the filename
- as represented internally in the PIFInfo object. Some functions
- such as PIFInfo_delete() will cause this pointer to become
- invalid.
-
- Return Values:
- On success PIFInfo_getExtension() returns the extension of the
- file. If the file does not have an extension this will be
- the empty string ("").
-
- Errors:
- If pFileInfo is NULL an error occurs PIFInfo_getExtension() returns
- NULL.
-
- More specific error information can be retrieved using
- PIPlatform_getLastError().
-
- See Also:
- PIFInfo_getPath().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI const char *PIFInfo_getExtension( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getFirstFileInDirectory
-
- Synopsis:
- PIFInfo *PIFInfo_getFirstFileInDirectory( PIFInfo *pFileInfo )
-
- Description:
- Returns a new PIFInfo object which contains information about the
- first file in the directory referred to by pFileInfo. This object
- can be used in subsequent calls to PIFInfo_getNextFileInDirectory() to
- iterate through all files in a directory.
-
- Notes:
- PIFInfo_getFirstFileInDirectory() allocates a new PIFInfo object,
- distinct from pFileInfo which must be seperately destroyed using
- PIFInfo_delete().
-
- Return Values:
- On success PIFInfo_getFirstFileInDirectory() returns a non-NULL pointer
- to a valid PIFInfo object.
-
- Errors:
- On error PIFInfo_getFirstFileInDirectory() returns NULL and
- PIPlatform_getLastError() can be used to retrieve an error code
- indicating the reason for the failure.
-
- See Also:
- PIFInfo_getNextFileInDirectory().
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI PIFInfo *PIFInfo_getFirstFileInDirectory( PIFInfo *pFileInfo );
-
- /*____________________________________________________________________________*\
- *
- Name:
- PIFInfo_getNextFileInDirectory
-
- Synopsis:
- int PIFInfo_getNextFileInDirectory( PIFInfo *pFileInfo )
-
- Description:
- Makes pFileInfo point to the next file in the directory. The object
- referred to by pFileInfo must have been created with a call to
- PIFInfo_getFirstFileInDirectory().
-
- Notes:
- If pFileInfo refers the last file in the directory,
- PIFInfo_getNextFileInDirectory() returns PIAPI_FALSE and pFileInfo
- does no refer to a valid file.
-
- Return Values:
- On success PIFInfo_getNextFileInDirectory() returns PIAPI_TRUE and
- pFileInfo points to the next file in the directory. If there
- are no other files in the directory or an error occurs
- PIFInfo_getNextFileInDirectory() returns PIAPI_FALSE.
- The object pFileInfo should be destroy using PIFInfo_delete() when
- it is no longer needed.
-
- Errors:
- On error PIFInfo_getNextFileInDirectory() returns PIAPI_FALSE and
- PIPlatform_getLastError() returns a value other than
- PIAPI_COMPLETED indicating which error occurred.
-
- See Also:
- PIFInfo_getFirstFileInDirectory()
- \*____________________________________________________________________________*/
- PUBLIC_PIAPI int PIFInfo_getNextFileInDirectory( PIFInfo *pFileInfo );
-
- #endif /* PIFINFO_H_ */
-
-