mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
c05de1f0a0
Signed-off-by: wuzhangda <wuzhangda@huawei.com> Change-Id: Ibfb512c6b86ac1ab103339c6e1043b56e9c6b612
75 lines
1.9 KiB
C++
75 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef ECMASCRIPT_PLATFORM_FILE_H
|
|
#define ECMASCRIPT_PLATFORM_FILE_H
|
|
|
|
#ifdef PANDA_TARGET_WINDOWS
|
|
#include <windef.h>
|
|
#include <winbase.h>
|
|
#include <winnt.h>
|
|
#else
|
|
#include <fcntl.h>
|
|
#include <dlfcn.h>
|
|
#endif
|
|
|
|
#include <string>
|
|
|
|
#include "ecmascript/ecma_string.h"
|
|
#include "ecmascript/js_tagged_value.h"
|
|
namespace panda::ecmascript {
|
|
#ifdef PANDA_TARGET_WINDOWS
|
|
using fd_t = HANDLE;
|
|
#define INVALID_FD INVALID_HANDLE_VALUE
|
|
|
|
#define FILE_RDONLY GENERIC_READ
|
|
#define FILE_WRONLY GENERIC_WRITE
|
|
#define FILE_RDWR (GENERIC_READ | GENERIC_WRITE)
|
|
|
|
#ifdef ERROR
|
|
#undef ERROR
|
|
#endif
|
|
|
|
#ifdef VOID
|
|
#undef VOID
|
|
#endif
|
|
|
|
#ifdef CONST
|
|
#undef CONST
|
|
#endif
|
|
#else
|
|
using fd_t = int;
|
|
#define INVALID_FD (-1)
|
|
|
|
#define FILE_RDONLY O_RDONLY
|
|
#define FILE_WRONLY O_WRONLY
|
|
#define FILE_RDWR O_RDWR
|
|
#endif
|
|
|
|
#define FILE_SUCCESS 1
|
|
#define FILE_FAILED 0
|
|
|
|
std::string GetFileDelimiter();
|
|
bool RealPath(const std::string &path, std::string &realPath, bool readOnly = true);
|
|
void DPrintf(fd_t fd, const std::string &buffer);
|
|
void Close(fd_t fd);
|
|
void FSync(fd_t fd);
|
|
MemMap FileMap(const char *fileName, int flag, int prot, int64_t offset = 0);
|
|
int FileUnMap(MemMap addr);
|
|
JSHandle<EcmaString> ResolveFilenameFromNative(JSThread *thread, JSTaggedValue dirname,
|
|
JSTaggedValue request);
|
|
} // namespace panda::ecmascript
|
|
#endif // ECMASCRIPT_PLATFORM_FILE_H
|