ftp.nice.ch/pub/next/graphics/convertors/Convert_MacPaint.NIHS.bs.tar.gz#/Convert_MacPaint/Source/shared.subproj/File.h

This is File.h in view mode; [Download] [Up]

/***********************************************************************\
Common class for accessing files in all Convert programs
Copyright (C) 1993 David John Burrowes

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

The author, David John Burrowes, can be reached at:
	davidjohn@kira.net.netcom.com
	David John Burrowes
	1926 Ivy #10
	San Mateo, CA 94403-1367
\***********************************************************************/

/*
====================================================================
This is the interface file for the File class.  Full documentation for this class can be found in the File.rtf file.  I will not duplicate all that fine information here.
	This is $Revision: 1.6 $ of this file
	It was last modified by $Author: death $ on $Date: 93/04/04 23:44:23 $
Note that this file was created while using the New Century Schoolbook Roman typeface.  You may find that some things line up strangely if you don't use that family.
 *$Log:	File.h,v $
 * Revision 1.6  93/04/04  23:44:23  death
 * Sun Apr  4 23:44:23 PDT 1993
 * 
 * Revision 1.5  93/01/10  15:07:53  death
 * Sun Jan 10 15:07:52 PST 1993
 * 
 * Revision 1.4  92/07/26  13:57:52  death
 * Update so all works with the font converter...
 * 
 * Revision 1.2  92/04/05  22:51:05  death
 * Miscelaneous revisions.  This is the last version of  version 1.
 * 
 * Revision 1.1  92/03/29  12:18:23  death
 * Initial revision
 * 
 *====================================================================
 */

//
// Import our parent class' definition
//
#import "ResultObject.h"
#import "common.h"
//
//	For stat info...
//
#include <sys/types.h>
#include <sys/stat.h>

//
// Define types for positions in the underlying file.
//
typedef	PositiveInteger	FilePos;
typedef	FilePos			FilePosDelta;
typedef	Integer			AccessType;

//
//
#define	fileAtEOF				1
#define	fileAtStart				2
#define	fileInMiddle				3

//
// Now, define our interface.   Again, see the File.rtf document for general info.
//
@interface File:ResultObject
{
	CString		FileName;
	AccessType	AccessMode;
	NXStream*	TheFile;
	ino_t		TheInode;
	Integer		FileLocation;
	Boolean		FileIsOpen;
}
	
- initAndUse:(roCString) pathname;
- initAndUseTemporary;
- CreateAndOpenFor: (AccessType) access;
- OpenExistingFor: (AccessType) access;
- ClearAndOpenExistingFor: (AccessType) access;
- ClearAndOpenFor: (AccessType) access;
- OpenFor: (AccessType) access;
- OpenWithAccess: (Integer) operation;
//
- CloseAndDelete;
- Close;
- CloseAndSave;
- free;
//
- AdvanceBytes: (FilePosDelta) byteLoc;
- BackupBytes: (FilePosDelta) byteLoc;
- (CString) GetBasename;
- (FilePos) GetCurrentPosition;
- (CString) GetExtension;
- (CString) GetFilename;
- (CString) GetPathname;
- (CString) GetDirectory;
- MoveTo: (PositiveInteger) byteLoc;
- (Byte) ReadByte;
- Read: (PositiveInteger) numBytes BytesInto: (ByteString) buffer;
- WriteByte: (Byte) theByte;
- Write: (PositiveInteger) numBytes BytesFrom: (ByteString) buffer;
- (PositiveInteger) FileSize;
- FileInfo;
-  (Boolean) SameFileAs: (CString) someOtherFile;
//
//	internal methods
//
-  (CString) GetFullPathFrom: (roCString) pathname;
- ClearFile: (CString) pathname;
- CreateFile: (CString) pathname;
-  (Boolean) FileExists: (CString) pathname;
@end




//
// Now, define some constants used by the class to define the kinds of errors that may occurr
//


#define FILE_READ			0
#define FILE_WRITE			1
#define FILE_READWRITE	2
#define FILE_APPEND		3
#define FILE_NOACCESS		-1
//
//	Error codes  (using 100 to -300)
//
#define	ERR_STRANGEPATH		50
#define	ERR_BADACCESS		-100
#define	ERR_FILENOTOPEN		-120
#define	ERR_CANTOPEN			-105
#define	ERR_CANTDELETE		-106
#define	ERR_FILEREADONLY	-150
#define	ERR_FILEWRITEONLY	-151
#define	ERR_FILEAPPENDONLY	-152
#define	ERR_NOSUCHFILE		-160
#define	ERR_CREATEFAIL		-170
#define	ERR_FILEEXISTS		-171
#define	ERR_SOMEFILEOPEN	-172
#define	ERR_FILEDOESNTEXIST	-173
#define	ERR_CLEARFAIL		-174
#define	ERR_WRITINGERROR	-200
#define	ERR_FLUSHINGERROR	-201
#define	ERR_WROTEBADCHAR	-202
#define	ERR_READINGERROR	-205
#define	ERR_BADBACKUP		-220
#define	ERR_BADADVANCE		-221
#define	ERR_NODIRECTORY		-250
#define	ERR_CANTGETINFO		-275
#define	ERR_EOF				-225

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.