-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new functions: pathListDir
, pathIsFile
, pathIsDirectory
#3189
Add new functions: pathListDir
, pathIsFile
, pathIsDirectory
#3189
Conversation
Is this supposed to return a list of files in a directory? |
Relative to a current resource, yes |
Is the Unix code block functional with |
|
Wouldn't it make more sense to append a directory separator for directory items? |
It might cause some issues when messing with directories directly via that function (unless mta takes care of that already)
No, it's not really expensive. If MTA doesn't have problems with directories ending with |
I don't think |
its better to have one function that gets all entries that you can sort by using |
There's the module FileSystem which already does the same and has some more features/functions btw. |
Using module for that will decrease performance (since you have to load the module, load its functions and events not to mention modules are very limited and you cant use almost any MTA functions there at all without refactoring the whole mta server). Implementing it directly in MTA solves all these issues |
Uhm I'm not sure if we really have these issues in the (FileSystem) module. But I do agree that having the functions client-side and being directly implemented into MTA is better. |
I doubt that modules can affect performance in a context of filesystem functions. The main disadvantage that modules have - they don't exist on a client side. So the only way to add proposed in this PR functions is to make them a part of MTA. But I personally would not say that these functions are really needed on a client side. Typically, server(and therefore client scripts) know which files exist on a client and how to reach them, which makes sense from the security perspective. |
5ba94b2
to
9da8617
Compare
0407443
to
c53dd92
Compare
pathListDir
pathListDir
, pathIsFile
, pathIsDirectory
ef5a412
to
316ebce
Compare
[ci skip]
VS2022: 17.6.33815.320 => 17.6.33829.357 [skip ci] This is an automated commit to keep track of toolchain changes on the build server. It applies to every MTA build after this commit until further notice.
VS2019: 16.11.33801.447 => 16.11.33920.266 [skip ci] This is an automated commit to keep track of toolchain changes on the build server. It applies to every MTA build after this commit until further notice.
[ci skip]
VS2019: 16.11.33927.289 => 16.11.34031.81 [skip ci] This is an automated commit to keep track of toolchain changes on the build server. It applies to every MTA build after this commit until further notice.
Build Tools 2022 (17.7.34031.279) This is an automated commit to keep track of toolchain changes on the build server. It applies to every MTA build after this commit until further notice. [skip ci]
For version control purposes
For version control purposes
For version control purposes, second-last one
242c3b9
to
b2571d6
Compare
…into 180923_Add-fileListDir
Cannot remove `#if __cplusplus >= 201703L` because client side code is using these functions (multiplayer_sa is c++14)
5cd45dd
to
6d52a20
Compare
`WIN32_TESTING` was changed to `_WIN32_TESTING`. Changed back to the original definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There's been many code reviews, so merging. |
Also refactored SharedUtil a little (
WIN32
might not be defined._WIN32
will always be defined)Syntax:
table fileListDir ( string path )
table pathListDir ( string path )
returns table of entries on success,
nil
on failureAdditional functions
bool isFile ( string path )
bool pathIsFile ( string path )
Returns true if path is a file, false if a directory or path doesn't exist
bool isDirectory ( string path )
bool pathIsDirectory ( string path )
Returns true if path is a directory, false if a file or path doesn't exist
OOP functions
path.listDir
=>pathListDir
path.isFile
=>pathIsFile
path.isDirectory
=>pathIsDirectory
Resolves: #346