Skip to content

Commit

Permalink
fs, feat: support file access switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Aug 4, 2018
1 parent 6405bf7 commit e54cf2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fibjs/include/Isolate.h
Expand Up @@ -139,6 +139,8 @@ class Isolate : public exlib::linkitem {
int32_t m_defaultMaxListeners;

int32_t m_exitCode;

bool m_bFileAccess;
};

} /* namespace fibjs */
Expand Down
1 change: 1 addition & 0 deletions fibjs/src/base/Runtime.cpp
Expand Up @@ -262,6 +262,7 @@ Isolate::Isolate(exlib::string fname)
, m_loglevel(console_base::_NOTSET)
, m_defaultMaxListeners(10)
, m_exitCode(0)
, m_bFileAccess(true)
{
m_fname = fname;

Expand Down
8 changes: 8 additions & 0 deletions fibjs/src/fs/fs.cpp
Expand Up @@ -246,6 +246,14 @@ result_t fs_base::openFile(exlib::string fname, exlib::string flags,
obj_ptr<File> pFile = new File();
result_t hr;

Isolate* isolate = ac->isolate();

if (isolate == NULL)
isolate = Isolate::current();

if (isolate && !isolate->m_bFileAccess)
return CHECK_ERROR(CALL_E_INVALID_CALL);

hr = pFile->open(safe_name, flags);
if (hr < 0)
return hr;
Expand Down

0 comments on commit e54cf2e

Please sign in to comment.