Gocator Development Kit
 All Classes Files Functions Variables Typedefs Friends Modules Pages
GdkFile.h
Go to the documentation of this file.
1 /**
2 * @file GdkFile.h
3 * @brief Declares the GdkFile class.
4 *
5 * Copyright (C) 2017-2022 by LMI Technologies Inc. All rights reserved.
6 */
7 #ifndef GDK_FILE_H
8 #define GDK_FILE_H
9 
10 #include <Gdk/GdkDef.h>
11 
12 /**
13 * Describes the interfaces to perform file operations from a Gdk tool.
14 *
15 * @class GdkFile
16 * @ingroup Gdk-Utils
17 */
18 
19 /**
20 * Read a file
21 *
22 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VProcess CALLBACK
23 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VStop CALLBACK
24 *
25 * @public @memberof GdkFile
26 * @param fileName Filename. (Name of the file to read from. Name must include "user/" in front of the file name. For example, "user/foo" to access file "foo").
27 * @param data Receives a pointer to a kArray1 containing the data.
28 * @return Operation status.
29 */
30 GdkFx(kStatus) GdkFile_Read(const kChar *fileName, kArray1* data);
31 
32 /**
33 * Write a file
34 *
35 * Do not write to files too often. (More than a few times per sensor startup)
36 * Sensor flash memory may be corrupted by excessive writes.
37 *
38 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VProcess CALLBACK
39 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VStop CALLBACK
40 *
41 * @public @memberof GdkFile
42 * @param fileName Filename. (Name of the file to be written to. Name must include "user/" in front of the file name. For example, "user/foo" to access file "foo").
43 * @param data Pointer to data to write to file.
44 * @param size Size of data to write to file.
45 * @return Operation status.
46 */
47 GdkFx(kStatus) GdkFile_Write(const kChar *fileName, const void* data, kSize size);
48 
49 /**
50 * How much flash memory is available to write to.
51 *
52 * @public @memberof GdkFile
53 * @return Available (bytes).
54 */
56 
57 /**
58 * How much flash memory has been used.
59 *
60 * @public @memberof GdkFile
61 * @return Used (bytes).
62 */
64 
65 /**
66 * Delete the file.
67 *
68 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VProcess CALLBACK
69 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VStop CALLBACK
70 *
71 * @public @memberof GdkFile
72 * @param fileName Filename. (Name of the file to be deleted. Name must include "user/" in front of the file name. For example, "user/foo" to access file "foo").
73 * @return Operation status.
74 */
75 GdkFx(kStatus) GdkFile_Delete(const kChar *fileName);
76 
77 /**
78 * Does the file exist within the user directory.
79 *
80 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VProcess CALLBACK
81 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VStop CALLBACK
82 *
83 * @public @memberof GdkFile
84 * @param fileName Filename. (Name of the file to determine existance. Name must include "user/" in front of the file name. For example, "user/foo" to access file "foo").
85 * @return File existance.
86 */
87 GdkFx(kBool) GdkFile_Exists(const kChar *fileName);
88 
89 /**
90 * Rename the file.
91 *
92 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VProcess CALLBACK
93 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VStop CALLBACK
94 *
95 * @public @memberof GdkFile
96 * @param from Current filename. (Name of the file to rename. Name must include "user/" in front of the file name. For example, "user/foo" to access file "foo").
97 * @param to To be renamed filename. (Name of the new file. Name must include "user/" in front of the file name. For example, "user/foonew" to access file "foonew").
98 * @return Operation status.
99 */
100 GdkFx(kStatus) GdkFile_Rename(const kChar *from, const kChar *to);
101 
102 /**
103 * Length of file - Query the file length (number of bytes in file).
104 *
105 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VProcess CALLBACK
106 * DO NOT CALL THIS FUNCTION FROM A GDK TOOL_VStop CALLBACK
107 *
108 * @public @memberof GdkFile
109 * @param fileName Filename. (Name of the file to be queried for length. Name must include "user/" in front of the file name. For example, "user/foo" to access file "foo").
110 * @return Length (bytes).
111 */
112 GdkFx(k64u) GdkFile_Length(const kChar *fileName);
113 
114 #endif
Essential Gdk declarations.
kStatus GdkFile_Delete(const kChar *fileName)
Delete the file.
kStatus GdkFile_Write(const kChar *fileName, const void *data, kSize size)
Write a file.
k64u GdkFile_UserStorageUsed()
How much flash memory has been used.
kStatus GdkFile_Read(const kChar *fileName, kArray1 *data)
Read a file.
k64u GdkFile_Length(const kChar *fileName)
Length of file - Query the file length (number of bytes in file).
k64u GdkFile_UserStorageFree()
How much flash memory is available to write to.
kBool GdkFile_Exists(const kChar *fileName)
Does the file exist within the user directory.
kStatus GdkFile_Rename(const kChar *from, const kChar *to)
Rename the file.