noggit3 icon indicating copy to clipboard operation
noggit3 copied to clipboard

Return nil when read_file not found file

Open Intemporel opened this issue 3 years ago • 3 comments
trafficstars

I think we can add return nil or something like that here : https://github.com/wowdev/noggit3/blob/74309b7cd33e19ae2b9e69160612d98eae3b8dcc/src/noggit/scripting/script_filesystem.cpp#L35

And in script we can now use read_file like that :

local myFile = read_file(path)

if ( myFile ) then
    ...
end

Intemporel avatar Dec 26 '21 10:12 Intemporel

      if (!fs::exists(path))
      {
        //throw script_exception("read_file","no such file:" + std::string (path));
        return false;
      }

Intemporel avatar Dec 26 '21 11:12 Intemporel

you have this: https://github.com/wowdev/noggit3/blob/default/scripts/docs/api/modules.md#path_exists

but could probably make two differentiating files and folders as well.

ihm-tswow avatar Dec 27 '21 10:12 ihm-tswow

i see this too late, lol

Intemporel avatar Dec 27 '21 15:12 Intemporel