<tbody><trid="row671818445506"><tdclass="cellrowborder"valign="top"width="45.540000000000006%"headers="mcps1.2.3.1.1 "><pid="p871814441501"><aname="p871814441501"></a><aname="p871814441501"></a>int UtilsFileOpen(const char* path, int oflag, int mode)</p>
</td>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p127181444165016"><aname="p127181444165016"></a><aname="p127181444165016"></a>Opens or creates a file.</p>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p1071884416504"><aname="p1071884416504"></a><aname="p1071884416504"></a>Closes a file with a specified file descriptor.</p>
</td>
</tr>
<trid="row6718744105017"><tdclass="cellrowborder"valign="top"width="45.540000000000006%"headers="mcps1.2.3.1.1 "><pid="p137181644145015"><aname="p137181644145015"></a><aname="p137181644145015"></a>int UtilsFileRead(int fd, char *buf, unsigned int len)</p>
</td>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p1171854410509"><aname="p1171854410509"></a><aname="p1171854410509"></a>Reads a specified length of data from a file with the specified file descriptor and writes the data into the buffer.</p>
</td>
</tr>
<trid="row2071817440509"><tdclass="cellrowborder"valign="top"width="45.540000000000006%"headers="mcps1.2.3.1.1 "><pid="p17718144465012"><aname="p17718144465012"></a><aname="p17718144465012"></a>int UtilsFileWrite(int fd, const char *buf, unsigned int len)</p>
</td>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p67191444145012"><aname="p67191444145012"></a><aname="p67191444145012"></a>Writes a specified length of data into a file with the specified file descriptor.</p>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p2071919446507"><aname="p2071919446507"></a><aname="p2071919446507"></a>Deletes a specified file.</p>
</td>
</tr>
<trid="row1071964425013"><tdclass="cellrowborder"valign="top"width="45.540000000000006%"headers="mcps1.2.3.1.1 "><pid="p20719114405010"><aname="p20719114405010"></a><aname="p20719114405010"></a>int UtilsFileStat(const char *path, unsigned int *fileSize)</p>
</td>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p8719144435015"><aname="p8719144435015"></a><aname="p8719144435015"></a>Obtains the file size.</p>
</td>
</tr>
<trid="row2071924417504"><tdclass="cellrowborder"valign="top"width="45.540000000000006%"headers="mcps1.2.3.1.1 "><pid="p57193447501"><aname="p57193447501"></a><aname="p57193447501"></a>int UtilsFileSeek(int fd, int offset, unsigned int whence)</p>
</td>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p1071934495014"><aname="p1071934495014"></a><aname="p1071934495014"></a>Adjusts the read and write position offset in a file.</p>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p113501041155511"><aname="p113501041155511"></a><aname="p113501041155511"></a>Copies the source file to a target file.</p>
<tdclass="cellrowborder"valign="top"width="54.459999999999994%"headers="mcps1.2.3.1.2 "><pid="p921744595517"><aname="p921744595517"></a><aname="p921744595517"></a>Moves the source file into a target file.</p>
</td>
</tr>
</tbody>
</table>
| Function | Description |
| ---------- | ------------- |
| int UtilsFileOpen(const char* path, int oflag, int mode) | Opens or creates a file. |
| int UtilsFileClose(int fd) | Closes a file with a specified file descriptor. |
| int UtilsFileRead(int fd, char *buf, unsigned int len) | Reads a specified length of data from a file with the specified file descriptor and writes the data into the buffer. |
| int UtilsFileWrite(int fd, const char *buf, unsigned int len) | Writes a specified length of data into a file with the specified file descriptor. |
| int UtilsFileDelete(const char *path) | Deletes a specified file. |
| int UtilsFileStat(const char *path, unsigned int *fileSize) | Obtains the file size. |
| int UtilsFileSeek(int fd, int offset, unsigned int whence) | Adjusts the read and write position offset in a file. |
| int UtilsFileCopy(const char* src, const char* dest) | Copies the source file to a target file. |
| int UtilsFileMove(const char* src, const char* dest) | Moves the source file into a target file. |
Sample code for file operations:
...
...
@@ -92,30 +50,12 @@ printf("delete ret = %d\n", ret);
<tbody><trid="row34145016535"><tdclass="cellrowborder"valign="top"width="57.38999999999999%"headers="mcps1.2.3.1.1 "><pid="p980953910190"><aname="p980953910190"></a><aname="p980953910190"></a>int UtilsGetValue(const char* key, char* value, unsigned int len)</p>
</td>
<tdclass="cellrowborder"valign="top"width="42.61%"headers="mcps1.2.3.1.2 "><pid="p13562171015712"><aname="p13562171015712"></a><aname="p13562171015712"></a>Obtains the value matching a specified key from the file system or cache.</p>
<tdclass="cellrowborder"valign="top"width="42.61%"headers="mcps1.2.3.1.2 "><pid="p2431455765"><aname="p2431455765"></a><aname="p2431455765"></a>Adds or updates the value matching a specified key in the file system or cache.</p>
<tdclass="cellrowborder"valign="top"width="42.61%"headers="mcps1.2.3.1.2 "><pid="p126575774517"><aname="p126575774517"></a><aname="p126575774517"></a>Deletes the value matching a specified key from the file system or cache.</p>
</td>
</tr>
</tbody>
</table>
| Function | Description |
| ----------- | ---------------- |
| int UtilsGetValue(const char* key, char* value, unsigned int len) | Obtains the value matching a specified key from the file system or cache. |
| int UtilsSetValue(const char* key, const char* value) | Adds or updates the value matching a specified key in the file system or cache. |
| int UtilsDeleteValue(const char* key) | Deletes the value matching a specified key from the file system or cache. |
Sample code for the KV store:
...
...
@@ -280,5 +220,3 @@ printf("UtilsDeleteValue delete ret = %d\n", ret);
**Figure 2** Output of the system attribute dumping command for the LiteOS Cortex-A kernel<a name="fig2179718143018"></a>