-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDKFile.h
More file actions
60 lines (41 loc) · 2.02 KB
/
Copy pathDKFile.h
File metadata and controls
60 lines (41 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// =======================================================================================
//
// DKFile.h
// Duck Object Library -- See LICENSE for legal information.
//
// Copyright (c) 2014-2026 Derek W. Nylen
//
// =======================================================================================
#ifndef _DK_FILE_H_
#define _DK_FILE_H_
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct DKFile * DKFileRef;
DK_API DKClassRef DKFileClass( void );
#define DKFile( filename, mode ) DKAutorelease( DKFileOpen( filename, mode ) )
#define DKNewFile( filename, mode ) DKFileOpen( filename, mode )
#define DKFileWithStreamPtr( stream, closeOnDealloc ) DKAutorelease( DKFileInitWithStreamPtr( DKAlloc( DKFileClass() ), stream, closeOnDealloc ) )
#define DKNewFileWithStreamPtr( stream, closeOnDealloc ) DKFileInitWithStreamPtr( DKAlloc( DKFileClass() ), stream, closeOnDealloc )
DK_API DKFileRef DKFileInitWithStreamPtr( DKObjectRef _self, FILE * stream, bool closeOnDealloc );
// Returns true if the file exists
DK_API bool DKFileExists( DKStringRef filename );
// Delete a file
DK_API void DKDeleteFile( DKStringRef filename );
// Create and open a new file - the returned object must be closed or released
DK_API DKFileRef DKFileOpen( DKStringRef filename, const char * mode );
// Close the file and release the object reference
DK_API int DKFileClose( DKFileRef _self );
DK_API FILE * DKFileGetStreamPtr( DKFileRef _self );
DK_API int DKFileSeek( DKFileRef _self, long offset, int origin );
DK_API long DKFileTell( DKFileRef _self );
DK_API int DKFileGetStatus( DKFileRef _self );
DK_API DKIndex DKFileGetLength( DKFileRef _self );
DK_API size_t DKFileRead( DKFileRef _self, void * buffer, size_t size, size_t count );
DK_API size_t DKFileWrite( DKFileRef _self, const void * buffer, size_t size, size_t count );
DK_API int DKFileFlush( DKFileRef _self );
#ifdef __cplusplus
}
#endif
#endif // _DK_FILE_H_