Skip to content

Commit

Permalink
Patch2
Browse files Browse the repository at this point in the history
Co-Authored-By: loathing <[email protected]>
  • Loading branch information
unknown-gd and amanitasolanaceae committed Jul 6, 2023
1 parent c9f12e6 commit d7bfd99
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 58 deletions.
111 changes: 54 additions & 57 deletions lua/gpm/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,16 @@ function IsFile( ... )
return Exists( ... ) and not IsDir( ... )
end

if MENU_DLL then
function MountGMA( gmaPath )
error( "Not yet implemented." )
end
else
function MountGMA( gmaPath )
error( "Not yet implemented." )
end

if not MENU_DLL then
function MountGMA( gmaPath )
local ok, files = game_MountGMA( gmaPath )
if ok then
if CLIENT then
for _, filePath in ipairs( files ) do
table.insert( MountedFiles, 1, filePath )
end
for _, filePath in ipairs( files ) do
table.insert( MountedFiles, 1, filePath )
end

logger:Debug( "GMA file '%s' was mounted to GAME with %d files.", gmaPath, #files )
Expand All @@ -77,70 +75,69 @@ else
end
end

if not ( SERVER or MENU_DLL ) then

if type( MountedFiles ) ~= "table" then
MountedFiles = {}
end
if type( MountedFiles ) ~= "table" then
MountedFiles = {}
end

local gamePaths = {
["LUA"] = "lua",
["lsv"] = "lua",
["lcl"] = "lua"
}
local gamePaths = {
["LUA"] = "lua",
["lsv"] = "lua",
["lcl"] = "lua"
}

-- https://github.com/Facepunch/garrysmod-issues/issues/5481
function IsMounted( filePath, gamePath, onlyDir )
if onlyDir and string.GetExtensionFromFilename( filePath ) then return end
-- https://github.com/Facepunch/garrysmod-issues/issues/5481
function IsMounted( filePath, gamePath, onlyDir )
if onlyDir and string.GetExtensionFromFilename( filePath ) then return end

local additional = gamePaths[ gamePath ]
if additional then
filePath = additional .. "/" .. filePath
end

for _, mountedFile in ipairs( MountedFiles ) do
if string.StartsWith( mountedFile, filePath ) then return true end
end
local additional = gamePaths[ gamePath ]
if additional then
filePath = additional .. "/" .. filePath
end

return false
for _, mountedFile in ipairs( MountedFiles ) do
if string.StartsWith( mountedFile, filePath ) then return true end
end

function Exists( filePath, gamePath )
if IsMounted( filePath, gamePath ) then return true end
if file.Exists( filePath, gamePath ) then return true end
return false
end

local files, folders = file.Find( filePath .. "*", gamePath )
if not files or not folders then return false end
if #files == 0 and #folders == 0 then return false end
function Exists( filePath, gamePath )
if IsMounted( filePath, gamePath ) then return true end
if file.Exists( filePath, gamePath ) then return true end
if SERVER then return false end

local splits = string.Split( filePath, "/" )
local fileName = splits[ #splits ]
local files, folders = file.Find( filePath .. "*", gamePath )
if not files or not folders then return false end
if #files == 0 and #folders == 0 then return false end

return table.HasIValue( files, fileName ) or table.HasIValue( folders, fileName )
end
local splits = string.Split( filePath, "/" )
local fileName = splits[ #splits ]

function IsDir( filePath, gamePath )
if IsMounted( filePath, gamePath, true ) then return true end
if file.IsDir( filePath, gamePath ) then return true end
return table.HasIValue( files, fileName ) or table.HasIValue( folders, fileName )
end

local _, folders = file.Find( filePath .. "*", gamePath )
if folders == nil or #folders == 0 then return false end
function IsDir( filePath, gamePath )
if IsMounted( filePath, gamePath, true ) then return true end
if file.IsDir( filePath, gamePath ) then return true end
if SERVER then return false end

local splits = string.Split( filePath, "/" )
return table.HasIValue( folders, splits[ #splits ] )
end
local _, folders = file.Find( filePath .. "*", gamePath )
if folders == nil or #folders == 0 then return false end

function IsFile( filePath, gamePath )
if IsMounted( filePath, gamePath ) then return true end
if file.Exists( filePath, gamePath ) and not file.IsDir( filePath, gamePath ) then return true end
local splits = string.Split( filePath, "/" )
return table.HasIValue( folders, splits[ #splits ] )
end

local files, _ = file.Find( filePath .. "*", gamePath )
if not files or #files == 0 then return false end
local splits = string.Split( filePath, "/" )
function IsFile( filePath, gamePath )
if IsMounted( filePath, gamePath ) then return true end
if file.Exists( filePath, gamePath ) and not file.IsDir( filePath, gamePath ) then return true end
if SERVER then return false end

return table.HasIValue( files, splits[ #splits ] )
end
local files, _ = file.Find( filePath .. "*", gamePath )
if not files or #files == 0 then return false end
local splits = string.Split( filePath, "/" )

return table.HasIValue( files, splits[ #splits ] )
end

function IsLuaFile( filePath, gamePath, compileMoon )
Expand Down
2 changes: 1 addition & 1 deletion lua/gpm/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Msg( [[

module( "gpm", package.seeall )

_VERSION = 013901
_VERSION = 013902

if not Colors then
Realm = "unknown"
Expand Down

0 comments on commit d7bfd99

Please sign in to comment.