gm_vfs - Abusing Valves Virtual Filesystem, Jailed binary support

What’s this?
Basically this works like the addon directory everything that lands on the directory ‘<root>/garrysmod/vfs’ can be used from the filesystem like with the addons, as it will add the search path for it. The advantage in this is you can for example download things with http.Get without destroying your addons or root directory while everything sits clean in vfs.

Why would I need that
Haven’t you ever though about sending all models and sounds and who knows what else while the player is already on the server? With this it is possible.


vfs.Open(file, mode)
r - Read
w - Write
a - Append
b - Binary
t - Text


vfs.Write(handle, write_type, type_params)
Write Types:
VFS_WRITE_DATA, data, size
VFS_WRITE_UINT32, number
VFS_WRITE_UINT16, number

vfs.Read(handle, read_type)
Read Types:

vfs.Seek(handle, pos, method)
Seek Methods:




Source Code


Keep in mind everything you write/read will only happen in <root>/garrysmod/vfs, you can also NOT escape via …/ or …\ you can also NOT use the absolute paths like C:\ something

Edit: Looks like the code tag is somewhat broken as it adds a lot of space after the code, so I’ll use the lua tag for now.

SO this sends files to the client into Garrysmod/vfs while connected to the server?

No this dll sends nothing, you can if you want however. Also the files will be usable like the stuff you put in addons, as I’m adding the directory ‘vfs’ into the search paths.

Can you tell us what the functions return if they return anything at all?

So basicly this module adds another folder to the file system, and the filesystem functions to write/read to it ?

What are the restricts to what can be sent assuming their are some?

I will post later an example as soon its done. The example will send the client a download url which has 2 php files, one is for creating a cached manifest file and the other php file is for sending the client the file list including the crc32.

Now when the client receives the list, its going to start downloading all files and puts them onto ‘garrysmod/vfs’ which makes all files available to the game.

I will also try to work on a system to reload model files that have been missing.

Edit: Heres the current progress:

Do the clients need to have this in order for it to work the way you are telling us?



Has this got a speed cap for downloading files?

Idk, does http.Get has a speedcap ?

Guess I should have actually looked at OP

afaik, can do exactly this, but without the user needing any dll.

gm_sourcenet3 is a dll, so either I don’t get your post or you are wrong. Also as what I know the transfer system is not using http at all.

Also see this

Sourcenet only needs to be installed serverside to transfere files to the client.

I can already see some benefits from it over sourcenet. Does that have any form of tracking for download progress?

It does, also this module needs to be installed on the client making it pretty useless

Why would you use http when source got a inbuilt file transfer system, I just don’t get the point of this module, except that you can put them in that special folder.
Also, what was that “gm_sourcenet3 is a dll”, isn’t this a dll too?

And lastly, the lua needed is just a base for transferring easier. I don’t get your point?

How is http slower afaik the inbuilt file transfer system is capped to around 100kbps why do you think people use fast-download?