openharmony_ci 40fd72fd7c !163 merge master into master
The commonlibrary_utils_lite has been migrated to GitCode, and the code contains a link to Gitee

Created-by: xwx1135370
Commit-by: xwx1135370
Merged-by: openharmony_ci
Description: ### 相关的Issue
https://gitcode.com/openharmony/commonlibrary_utils_lite/issues/100
  
### 原因(目的、解决的问题等)
commonlibrary_utils_lite已迁移至gitcode,代码里存在gitee链接

### 描述(做了什么,变更了什么)
更新gitee链接为gitcode链接

### 测试用例(新增、改动、可能影响的功能)
代码中搜索gitee关键字    
    
### 是否已执行L0用例
- [ ] 已验证
- [ ] 不涉及。如不涉及,请写明理由


See merge request: openharmony/commonlibrary_utils_lite!163
2026-02-27 14:54:47 +08:00
2025-11-06 12:22:45 +08:00
2023-04-14 10:14:28 +08:00
2023-08-10 15:56:35 +08:00
2023-04-14 10:14:28 +08:00
2023-07-12 09:57:51 +08:00
2022-03-25 15:56:32 +08:00

commonlibrary/utils_lite

Overview

The utils_lite repository stores basic components of OpenHarmony. These basic components are used by OpenHarmony subsystems and upper-layer applications.

The utils_lite library provides the following capabilities on different platforms:

  • LiteOS Cortex-M (Hi3861 platform): file operations and timer
  • LiteOS Cortex-A (Hi3516 or Hi3518 platform): timer and JavaScript APIs for device query and data storage

Table 1 Utils_lite capabilities

Module

Platform

Description

File operation

LiteOS Cortex-M

Provides unified file operation interfaces that can be used on different underlying chip components.

Timer

LiteOS Cortex-M and LiteOS Cortex-A

Provides unified timer operation interfaces that can be used on different underlying chip components.

JavaScript API

LiteOS Cortex-A

Provides JavaScript APIs for obtaining device information and storing data.

Directory Structure

commonlibrary/utils_lite/              # Root directory
├── file                        # Implementation of the file system APIs
├── hals                        # HAL directory
│   └── file                    # Header files of the hardware abstraction layer for file operations
├── include                     # Header files of external APIs
├── js                          # JavaScript APIs
│   └── builtin
│       ├── common              # Builtin common function
│       ├── deviceinfokit       # Device information kit
│       ├── filekit             # File kit
│       └── kvstorekit          # KV store kit
├── kal                         # KAL directory
│   └── timer                   # KAL implementation of the timer
├── memory
│   └── include                 # Memory pool management APIs
└── timer_task                  # Timer implementation

Usage

  • File operation

    // Open or create a file.
    const char fileName[] = "testfile";
    int fd = UtilsFileOpen(fileName, O_RDWR_FS | O_CREAT_FS | O_TRUNC_FS, 0);
    
    // Write a specified length of data into a file with the specified file descriptor.
    const char defValue[] = "test case of file system.";
    int ret = UtilsFileWrite(fd, defValue, strlen(defValue));
    
    // Close a file with a specified file descriptor.
    UtilsFileClose(fd);
    
    // Obtain the file size.
    int fileLen = 0;
    ret = UtilsFileStat(fileName, &fileLen);
    printf("file size = %d\n", fileLen);
    
    // Adjust the read and write position offset in a file.
    int fd1 = UtilsFileOpen(fileName, O_RDWR_FS, 0);
    ret = UtilsFileSeek(fd1, 5, SEEK_SET_FS);
    
    // Read a specified length of data from a file with the specified file descriptor and write the data into the buffer.
    char buf[32] = {0};
    int readLen = UtilsFileRead(fd1, buf, 32);
    ret = UtilsFileClose(fd1);
    printf("read len = %d : buf = %s\n", readLen, buf);
    
    // Delete a specified file.
    ret = UtilsFileDelete(fileName);
    

Repositories Involved

commonlibrary

commonlibrary_utils_lite

S
Description
暂无描述
Readme 821 KiB
Languages
C 61%
C++ 37.1%
CMake 1.9%