summaryrefslogtreecommitdiffhomepage
path: root/SDK/Developer/CoreSystem/Sources/File.c
blob: 40cbd5156bb6ee0a53df95ae4f0748c9285a84d0 (plain)
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
/* -------------------------------------------

    Copyright Mahrouss Logic

------------------------------------------- */

#include <Headers/Defines.h>
#include <Headers/File.h>

enum FileOp
{
	kFlushFile,
	kReadFork,
	kWriteFork,
	kOpenFork,
	kCloseFork,
};

/// @brief Opens a new file.
/// @param path where to find it.
/// @param rest the restrict (rw, rwe, r+, w+, r, w)
/// @return FSRef the file.
CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path,
							 const CharacterTypeUTF8* rest)
{
	CA_MUST_PASS(kSharedApplication);
	CA_MUST_PASS(path && FsIsValidPath(path) == Yes);
	CA_MUST_PASS(rest);

	return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path,
									  rest);
}

/// @brief Closes the file and flushes it to the said file.
/// @param refFs the filesystem reference.
/// @return
CA_EXTERN_C VoidType FsCloseFile(FSRef refFs)
{
	CA_MUST_PASS(kSharedApplication);

	kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile);
	kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs);
}