Skip to content

Commit

Permalink
src: move FsStatsOffset and kFsStatsBufferLength to node_file.h
Browse files Browse the repository at this point in the history
To avoid bloating env.h, as they are only used in node_file.*

PR-URL: #45498
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daeyeon Jeong <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and danielleadams committed Jan 3, 2023
1 parent 581b38a commit fbfd26d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,6 @@ class ModuleWrap;
class Environment;
class Realm;

enum class FsStatsOffset {
kDev = 0,
kMode,
kNlink,
kUid,
kGid,
kRdev,
kBlkSize,
kIno,
kSize,
kBlocks,
kATimeSec,
kATimeNsec,
kMTimeSec,
kMTimeNsec,
kCTimeSec,
kCTimeNsec,
kBirthTimeSec,
kBirthTimeNsec,
kFsStatsFieldsNumber
};

// Stat fields buffers contain twice the number of entries in an uv_stat_t
// because `fs.StatWatcher` needs room to store 2 `fs.Stats` instances.
constexpr size_t kFsStatsBufferLength =
static_cast<size_t>(FsStatsOffset::kFsStatsFieldsNumber) * 2;

// Disables zero-filling for ArrayBuffer allocations in this scope. This is
// similar to how we implement Buffer.allocUnsafe() in JS land.
class NoArrayBufferZeroFillScope {
Expand Down
27 changes: 27 additions & 0 deletions src/node_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ namespace fs {

class FileHandleReadWrap;

enum class FsStatsOffset {
kDev = 0,
kMode,
kNlink,
kUid,
kGid,
kRdev,
kBlkSize,
kIno,
kSize,
kBlocks,
kATimeSec,
kATimeNsec,
kMTimeSec,
kMTimeNsec,
kCTimeSec,
kCTimeNsec,
kBirthTimeSec,
kBirthTimeNsec,
kFsStatsFieldsNumber
};

// Stat fields buffers contain twice the number of entries in an uv_stat_t
// because `fs.StatWatcher` needs room to store 2 `fs.Stats` instances.
constexpr size_t kFsStatsBufferLength =
static_cast<size_t>(FsStatsOffset::kFsStatsFieldsNumber) * 2;

class BindingData : public SnapshotableObject {
public:
explicit BindingData(Environment* env, v8::Local<v8::Object> wrap);
Expand Down

0 comments on commit fbfd26d

Please sign in to comment.