15bebb993Sopenharmony_ci/*
25bebb993Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
35bebb993Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45bebb993Sopenharmony_ci * you may not use this file except in compliance with the License.
55bebb993Sopenharmony_ci * You may obtain a copy of the License at
65bebb993Sopenharmony_ci *
75bebb993Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
85bebb993Sopenharmony_ci *
95bebb993Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105bebb993Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115bebb993Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125bebb993Sopenharmony_ci * See the License for the specific language governing permissions and
135bebb993Sopenharmony_ci * limitations under the License.
145bebb993Sopenharmony_ci */
155bebb993Sopenharmony_ci
165bebb993Sopenharmony_ci#ifndef OHOS_FILE_FS_RANDOMACCESSFILE_IMPL_H
175bebb993Sopenharmony_ci#define OHOS_FILE_FS_RANDOMACCESSFILE_IMPL_H
185bebb993Sopenharmony_ci
195bebb993Sopenharmony_ci#include "utils.h"
205bebb993Sopenharmony_ci#include "uni_error.h"
215bebb993Sopenharmony_ci#include "ffi_remote_data.h"
225bebb993Sopenharmony_ci#include "cj_common_ffi.h"
235bebb993Sopenharmony_ci#include "randomaccessfile_entity.h"
245bebb993Sopenharmony_ci
255bebb993Sopenharmony_ci#include <cstdint>
265bebb993Sopenharmony_ci#include <string>
275bebb993Sopenharmony_ci
285bebb993Sopenharmony_cinamespace OHOS {
295bebb993Sopenharmony_cinamespace CJSystemapi {
305bebb993Sopenharmony_ciclass RandomAccessFileImpl : public OHOS::FFI::FFIData {
315bebb993Sopenharmony_cipublic:
325bebb993Sopenharmony_ci    explicit RandomAccessFileImpl(std::shared_ptr<OHOS::FileManagement::ModuleFileIO::RandomAccessFileEntity> entity);
335bebb993Sopenharmony_ci    int32_t GetFd();
345bebb993Sopenharmony_ci    int64_t GetFPointer();
355bebb993Sopenharmony_ci    void SetFilePointerSync(int64_t fp);
365bebb993Sopenharmony_ci    void CloseSync();
375bebb993Sopenharmony_ci    std::tuple<int32_t, int64_t> WriteSync(char* buf, size_t len, int64_t offset);
385bebb993Sopenharmony_ci    std::tuple<int32_t, int64_t> ReadSync(char* buf, size_t len, int64_t offset);
395bebb993Sopenharmony_ci
405bebb993Sopenharmony_ci    OHOS::FFI::RuntimeType* GetRuntimeType() override { return GetClassType(); }
415bebb993Sopenharmony_ciprivate:
425bebb993Sopenharmony_ci    std::shared_ptr<OHOS::FileManagement::ModuleFileIO::RandomAccessFileEntity> entity_;
435bebb993Sopenharmony_ci
445bebb993Sopenharmony_ci    friend class OHOS::FFI::RuntimeType;
455bebb993Sopenharmony_ci    friend class OHOS::FFI::TypeBase;
465bebb993Sopenharmony_ci    static OHOS::FFI::RuntimeType* GetClassType()
475bebb993Sopenharmony_ci    {
485bebb993Sopenharmony_ci        static OHOS::FFI::RuntimeType runtimeType =
495bebb993Sopenharmony_ci            OHOS::FFI::RuntimeType::Create<OHOS::FFI::FFIData>("RandomAccessFileImpl");
505bebb993Sopenharmony_ci        return &runtimeType;
515bebb993Sopenharmony_ci    }
525bebb993Sopenharmony_ci};
535bebb993Sopenharmony_ci} // OHOS::FileManagement::ModuleFileIO
545bebb993Sopenharmony_ci}
555bebb993Sopenharmony_ci
565bebb993Sopenharmony_ci#endif // OHOS_FILE_FS_IMPL_H