Skip to content

Commit

Permalink
Fixed CI, fixed #336 (I think), fixed #330
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 committed Dec 7, 2023
1 parent 5da725f commit 8dbd561
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion craftos2-lua
Submodule craftos2-lua updated 2 files
+0 −1 src/ldo.c
+16 −6 src/lvm.c
4 changes: 2 additions & 2 deletions examples/ccemux.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;SDL2.lib;lua51.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;SDL2.lib;lua52.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)craftos2-lua\src</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
Expand Down Expand Up @@ -212,7 +212,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;SDL2d.lib;lua51d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;SDL2d.lib;lua52d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)craftos2-lua\src</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/apis/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static int fs_open(lua_State *L) {
if (d.isDir) {
lua_remove(L, fpid);
lua_pushnil(L);
if (strchr(mode, 'r') != NULL) lua_pushfstring(L, "/%s: No such file", fixpath(computer, str, false, false).string().c_str());
if (strchr(mode, 'r') != NULL) lua_pushfstring(L, "/%s: Not a file", fixpath(computer, str, false, false).string().c_str());
else lua_pushfstring(L, "/%s: Cannot write to directory", fixpath(computer, str, false, false).string().c_str());
return 2;
}
Expand All @@ -491,7 +491,7 @@ static int fs_open(lua_State *L) {
std::error_code e;
if (fs::is_directory(path, e)) {
lua_pushnil(L);
if (strchr(mode, 'r') != NULL) lua_pushfstring(L, "/%s: No such file", fixpath(computer, str, false, false).string().c_str());
if (strchr(mode, 'r') != NULL) lua_pushfstring(L, "/%s: Not a file", fixpath(computer, str, false, false).string().c_str());
else lua_pushfstring(L, "/%s: Cannot write to directory", fixpath(computer, str, false, false).string().c_str());
return 2;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apis/handles/http_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int http_handle_free(lua_State *L) {
int http_handle_close(lua_State *L) {
lastCFunction = __func__;
http_handle_t** handle = (http_handle_t**)lua_touserdata(L, lua_upvalueindex(1));
if (*handle == NULL) return luaL_error(L, "attempt to use a closed file");
if (*handle == NULL) return 0;
delete (*handle)->handle;
delete (*handle)->session;
delete *handle;
Expand Down
4 changes: 2 additions & 2 deletions src/apis/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,9 @@ static int websocket_free(lua_State *L) {
static int websocket_close(lua_State *L) {
lastCFunction = __func__;
ws_handle * ws = *(ws_handle**)lua_touserdata(L, lua_upvalueindex(1));
if (ws == NULL) luaL_error(L, "attempt to use a closed file");
if (ws == NULL) return 0;
std::lock_guard<std::mutex> lock(ws->lock);
if (ws->ws == NULL) luaL_error(L, "attempt to use a closed file");
if (ws->ws == NULL) return 0;
ws->ws = NULL;
return 0;
}
Expand Down
35 changes: 22 additions & 13 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,29 @@ path_t fixpath(Computer *comp, const std::string& path, bool exists, bool addExt
if (!found) return path_t();
} else if (pathc.size() > 1) {
bool found = false;
std::string back = pathc.back();
pathc.pop_back();
for (const _path_t& p : max_path.second) {
path_t sstmp = p;
for (const std::string& s : pathc) sstmp /= s;
e.clear();
if (
(isVFSPath(p) && (nothrow(comp->virtualMounts[(unsigned)std::stoul(p.substr(0, p.size()-1))]->path(ss/back)) ||
(nothrow(comp->virtualMounts[(unsigned)std::stoul(p.substr(0, p.size()-1))]->path(sstmp)) && comp->virtualMounts[(unsigned)std::stoul(p.substr(0, p.size()-1))]->path(sstmp).isDir))) ||
(fs::exists(sstmp/back, e)) || (fs::is_directory(sstmp, e))) {
ss /= sstmp/back;
found = true;
break;
std::stack<std::string> oldback;
while (!found && !pathc.empty()) {
found = false;
std::string back = pathc.back();
pathc.pop_back();
for (const _path_t& p : max_path.second) {
path_t sstmp = p;
for (const std::string& s : pathc) sstmp /= s;
e.clear();
if (
(isVFSPath(p) && (nothrow(comp->virtualMounts[(unsigned)std::stoul(p.substr(0, p.size()-1))]->path(ss/back)) ||
(nothrow(comp->virtualMounts[(unsigned)std::stoul(p.substr(0, p.size()-1))]->path(sstmp)) && comp->virtualMounts[(unsigned)std::stoul(p.substr(0, p.size()-1))]->path(sstmp).isDir))) ||
(fs::exists(sstmp/back, e)) || (fs::is_directory(sstmp, e))) {
ss /= sstmp/back;
while (!oldback.empty()) {
ss /= oldback.top();
oldback.pop();
}
found = true;
break;
}
}
if (!found) oldback.push(back);
}
if (!found) return path_t();
} else {
Expand Down

0 comments on commit 8dbd561

Please sign in to comment.