• file.Read/Write limited?
    11 replies, posted
I'm having a small issue with writing a file to the data folder. [lua] file.Write("testing.txt", "bumble") [/lua] The above code writes a file to the directory garrysmod/data. Thus being garrysmod/data/testing.txt Correct? [lua] file.Read("testing.txt") [/lua] This above code reads the file and all of its content of garrysmod/data/testing.txt, Nothing wrong is there. Now, what if we want to write a file to the garrysmod/gamemodes/myGamemode/content/data folder? [b]Answer:[/b] You can't, [i]not without a DLL anyway[/i] However, you can read from the gamemodes/content/data directory just fine. Lets say you made a text file in [i]garrysmod/gamemodes/myGamemode/content/data[/i], called it "[i]anothertest.txt[/i]" and inside the file put "[i]bee[/i]". Then ran: [lua]print( file.Read("anothertest.txt") )[/lua] Your output in the console would be, "[i]bee[/i]". So I ask, Why arn't we allowed to write files to our gamemodes data folder, yet we can read it? I wanted to write to my gamemode folder to keep everything together, keep the data folder from becoming a mess. Which yeah people will say organize your files into different directories. But what if I want to release my gamemode? I'll have to pack it into a rar and remove all the other text files which are not needed in the release or in any way related to the gamemode. Why can't we just have the option/function to write to our gamemodes data folder?
You could try this [lua]file.Write("../gamemodes/myGamemode/content/data/anothertest.txt", "bumble")[/lua]
I think Gmod just copies everything in /garrysmod/gamemode/myGamemode/content into the the /garrysmod/ directory, so the fact you can read /garrysmod/gamemode/myGamemode/content/data is just an accident. Same thing would probably happen if you put something in /garrysmod/addons/myAddon/data.
On my side that doesn't work MakeR, it doesn't even write to the garrysmod/data folder either.
[QUOTE=JSharpe;16600944]On my side that doesn't work MakeR, it doesn't even write to the garrysmod/data folder either.[/QUOTE] I believe you can't read/write anything outside the data folder. Both pages state this.
I suspect gmod mounts everything in garrysmod/gamemodes/myGamemode/content/ into garrysmod/, so as far as source knows the data folder inside the gamemode is the same as the data folder in the root. I could be wrong though..
[QUOTE=Vir;16600917]I think Gmod just copies everything in /garrysmod/gamemode/myGamemode/content into the the /garrysmod/ directory, so the fact you can read /garrysmod/gamemode/myGamemode/content/data is just an accident. Same thing would probably happen if you put something in /garrysmod/addons/myAddon/data.[/QUOTE] [QUOTE=thomasfn;16601661]I suspect gmod mounts everything in garrysmod/gamemodes/myGamemode/content/ into garrysmod/, so as far as source knows the data folder inside the gamemode is the same as the data folder in the root. I could be wrong though..[/QUOTE] These.
[QUOTE=Unrealomega;16601543]I believe you can't read/write anything outside the data folder. Both pages state this.[/QUOTE] My simple anticheat scans their Lua folder when people join my server. There are no restrictions against reading Lua files outside of the Data directory as far as I can tell.
u can use read becouse then an lua coder can check if users have files like wire or phx, or even make plugin systems at gamemode's or what ever u want to do. u cant write outside the data becouse else some bitch would make a script that spams ur hole Gmod folder full whit crappy textfiles or even ur C:\ or ur desktop.
[QUOTE=Mitsudigi;16602769]My simple anticheat scans their Lua folder when people join my server. There are no restrictions against reading Lua files outside of the Data directory as far as I can tell.[/QUOTE] [QUOTE=The-Stone;16537824][code] local fr = file.Read function file.Read(path) if path:find("../") then print("file.Read outside data blocked!") return "Blocked" end return fr(path) end [/code] Have fun trying to read 'aimbot' files ;)[/QUOTE] Anymore to say?
[QUOTE=The-Stone;16603084]Anymore to say?[/QUOTE] It's obviously not meant to catch anyone who knows what they're doing.
[QUOTE=Mitsudigi;16603285]It's obviously not meant to catch anyone who knows what they're doing.[/QUOTE] Why yes obviously. What about the people that download the scripts to bypass it? I guess they definitely know what they're doing too. But besides, leave that for the anti cheat thread. Isn't is some way possible to write files to just the gamemode/content/data folder?
Sorry, you need to Log In to post a reply to this thread.