Skip to content

Commit

Permalink
Add rawfile bindings
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Jan 11, 2025
1 parent 0fc7837 commit 542fe71
Show file tree
Hide file tree
Showing 14 changed files with 771 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ already been generated.
| ohcamera | | |
| purgeable_memory | | |
| qos | | |
| rawfile | | |
| rawfile | | 13 |
| resourcemanager | | |
| sensors | | |
| telephony | | |
Expand Down
5 changes: 5 additions & 0 deletions components/rawfile/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0

Initial release
28 changes: 28 additions & 0 deletions components/rawfile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "ohos-rawfile-sys"
version = "0.1.0"
edition = "2021"
description = "Raw Bindings to the rawfile API of OpenHarmony"
license = "Apache-2.0"
repository = "https://github.com/openharmony-rs/ohos-sys"
keywords = ["OpenHarmony", "HarmonyOS", "ffi", "rawfile", "file"]
readme = "README.md"

[dependencies]
document-features = { version = "0.2", optional = true }
ohos-sys-opaque-types = { workspace = true}

[features]
default = []

api-10 = []
api-11 = ["api-10"]
api-12 = ["api-11"]
api-13 = ["api-12"]
## Document available features when building the documentation
document-features = ["dep:document-features"]

[package.metadata.docs.rs]
features = ["document-features"]
targets = ["aarch64-unknown-linux-ohos", "armv7-unknown-linux-ohos", "x86_64-unknown-linux-ohos"]
all-features = true
8 changes: 8 additions & 0 deletions components/rawfile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# OpenHarmony rawfile bindings

The OpenHarmony rawfile API allows the user to access so-called `rawfile`s that are bundled
into the `hap` bundle.

## License

Licensed under the Apache-2.0 license, matching the license of OpenHarmony.
28 changes: 28 additions & 0 deletions components/rawfile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Bindings to the rawfile APIs
//!
//! ## Overview
//!
//! The OpenHarmony rawfile API allows the user to access so-called `rawfile`s that are bundled
//! into the `hap` bundle.
//!
//! You can use the APIs to traverse, open, search for, read, and close raw files.
//! The rawfile APIs are non-thread-safe. Only the close and open APIs are thread-safe.
//!
//! See also the [official rawfile documentation](https://docs.openharmony.cn/pages/v5.0/en/application-dev/reference/apis-localization-kit/rawfile.md).
//!
//!
//! ## Feature flags
#![cfg_attr(
feature = "document-features",
cfg_attr(doc, doc = ::document_features::document_features!())
)]
#![cfg_attr(docsrs, feature(doc_cfg))]

extern "C" {}

mod raw_file_types_ffi;
pub use raw_file_types_ffi::*;

pub mod raw_dir;
pub mod raw_file;
pub mod raw_file_manager;
2 changes: 2 additions & 0 deletions components/rawfile/src/raw_dir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod raw_dir_ffi;
pub use raw_dir_ffi::*;
59 changes: 59 additions & 0 deletions components/rawfile/src/raw_dir/raw_dir_ffi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

#[repr(C)]
pub struct RawDir {
_unused: [u8; 0],
}
extern "C" {
/// Obtains the name of the file according to the index.
///
/// You can use this method to traverse a raw file directory.
///
/// # Arguments
///
/// * `rawDir` - Indicates the pointer to [`RawDir`].
///
/// * `index` - Indicates the file index in [`RawDir`].
///
/// # Returns
///
/// * Returns the name of the file according to the index,
/// which can be passed to [`OH_ResourceManager_OpenRawFile`] as an input parameter;
/// returns <b>NULL</b> if all files are returned.
/// [`OH_ResourceManager_OpenRawFile`]
/// Available since API-level: 8
///
/// Version: 1.0
pub fn OH_ResourceManager_GetRawFileName(
rawDir: *mut RawDir,
index: ::core::ffi::c_int,
) -> *const ::core::ffi::c_char;
/// get the count of the raw files in [`RawDir`].
///
/// You can use this method to get the valid index of [`OH_ResourceManager_GetRawFileName`].
///
/// # Arguments
///
/// * `rawDir` - Indicates the pointer to [`RawDir`].
/// [`OH_ResourceManager_GetRawFileName`]
/// Available since API-level: 8
///
/// Version: 1.0
pub fn OH_ResourceManager_GetRawFileCount(rawDir: *mut RawDir) -> ::core::ffi::c_int;
/// Closes an opened [`RawDir`] and releases all associated resources.
///
///
///
/// # Arguments
///
/// * `rawDir` - Indicates the pointer to [`RawDir`].
/// [`OH_ResourceManager_OpenRawDir`]
/// Available since API-level: 8
///
/// Version: 1.0
pub fn OH_ResourceManager_CloseRawDir(rawDir: *mut RawDir);
}
2 changes: 2 additions & 0 deletions components/rawfile/src/raw_file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod raw_file_ffi;
pub use raw_file_ffi::*;
Loading

0 comments on commit 542fe71

Please sign in to comment.