Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rawfile bindings #69

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
36 changes: 36 additions & 0 deletions components/rawfile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[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 = ["_functions"]

## Internal feature: Enables functions
##
## Enabled by default. Users should not disable this feature.
## Removing this feature only leaves a couple of type definitions, which are required by some other
## OpenHarmony sys crates for interop. This allows us to make linking against `rawfile` shared library optional,
## and only happen if a user actually needs to use this crate.
_functions = []

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.
31 changes: 31 additions & 0 deletions components/rawfile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! 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::*;

#[cfg(feature = "_functions")]
pub mod raw_dir;
#[cfg(feature = "_functions")]
pub mod raw_file;
#[cfg(feature = "_functions")]
pub mod raw_file_manager;
5 changes: 5 additions & 0 deletions components/rawfile/src/raw_dir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod raw_dir_ffi;
pub use raw_dir_ffi::*;

#[link(name = "rawfile.z")]
extern "C" {}
61 changes: 61 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,61 @@
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#[cfg(doc)]
use crate::raw_file_manager::{OH_ResourceManager_OpenRawDir, OH_ResourceManager_OpenRawFile};

#[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);
}
5 changes: 5 additions & 0 deletions components/rawfile/src/raw_file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod raw_file_ffi;
pub use raw_file_ffi::*;

#[link(name = "rawfile.z")]
extern "C" {}
Loading
Loading