• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INTERFACES_KITS_JS_SRC_MOD_FS_CLASS_STAT_FS_STAT_H
17 #define INTERFACES_KITS_JS_SRC_MOD_FS_CLASS_STAT_FS_STAT_H
18 
19 #include "filemgmt_libfs.h"
20 #include "fs_stat_entity.h"
21 
22 namespace OHOS::FileManagement::ModuleFileIO {
23 using namespace std;
24 
25 const int64_t SECOND_TO_NANOSECOND = 1e9;
26 constexpr int S_PERMISSION = 00000777;
27 #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM)
28 const size_t MAX_ATTR_NAME = 64;
29 const std::string CLOUD_LOCATION_ATTR = "user.cloud.location";
30 #endif
31 class FsStat final {
32 public:
33     static FsStat *Constructor();
34 
GetStatEntity()35     StatEntity *GetStatEntity() const
36     {
37         return entity.get();
38     }
39 
40     bool IsBlockDevice();
41     bool IsCharacterDevice();
42     bool IsDirectory();
43     bool IsFIFO();
44     bool IsFile();
45     bool IsSocket();
46     bool IsSymbolicLink();
47 
48     int64_t GetIno();
49     int64_t GetMode();
50     int64_t GetUid();
51     int64_t GetGid();
52     int64_t GetSize();
53     int64_t GetAtime();
54     int64_t GetMtime();
55     int64_t GetCtime();
56     int64_t GetAtimeNs();
57     int64_t GetMtimeNs();
58     int64_t GetCtimeNs();
59 #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM)
60     int32_t GetLocation();
61 #endif
62 
63 private:
64     unique_ptr<StatEntity> entity;
65     bool CheckStatMode(mode_t mode);
FsStat(unique_ptr<StatEntity> entity)66     explicit FsStat(unique_ptr<StatEntity> entity) : entity(move(entity)) {};
67 };
68 } // namespace OHOS::FileManagement::ModuleFileIO
69 #endif // INTERFACES_KITS_JS_SRC_MOD_FS_CLASS_STAT_FS_STAT_H