[img]http://www.colzdragon.net/media/image/projects/hio/logo.png[/img]
Well.. I thought I might as well release my first module. Special thanks to Overv for teaching me fstream and thanks to a website I forget the name of for providing me with the C++ string formatting. This is basically gm_rawio, but smaller, with all of the same functions and more. Aswell as checksums to come. You can use partitions and when writing/reading the path defaults to garrysmod\\garrysmod\\.
[b]Functions:[/b]
[list]
[*]hIO.FileExists( file )
[*]hIO.DirExists( directory )
[*]hIO.Size( file )
[*]hIO.Write( file, contents )
[*]hIO.Read( file )
[*]hIO.Rename( oldname, newname )
[*]hIO.Remove( file )
[*]hIO.MakeDirectory( name )
[*]hIO.RemoveDirectory( name )
[/list]
[b]Examples:[/b]
[list]
[*][lua]
require "hio"
hook.Add( "PlayerInitialSpawn", "lolexample", function( ply )
hIO.Write( "lollogs\\joins.log", hIO.Read( "lollogs\\joins.log" ) .. "\n" .. string.format( "%s > %s > %s", ply:Nick( ), ply:SteamID( ), ply:IPAddress( ) ) );
end );
[/lua]
[*][lua]
require "hio"
hIO.Write( "C:\\lol.txt", "Hai" );
[/lua]
[*][lua]
require "hio"
print( hIO.Read( "scripts\\game.txt" ) )
[/lua]
[/list]
[b]Download:[/b]
[url=http://www.colzdragon.net/media/files/gm_hio.zip]Mirror 1[/url]
[url=http://dl.dropbox.com/u/6226565/Binary%20Modules/gm_hio.zip]Mirror 2[/url]
( The source and binaries are in the downloads )
Nice job broski.
Looks like gm_rawio but less functions
[QUOTE=Wizard of Ass;23398840]Looks like gm_rawio but less functions[/QUOTE]
gm_hio is basically a compact gm_rawio. It's only 13 kb, whereas gm_rawio is 56 kb.
Why you don't make this much more than just gm_rawio ?
You could add function to read the change/creation date filesize etc.
Maybe add a function to read file's CRC-hash?
Okay, I'll start work on it :eng101:
[editline]08:28AM[/editline]
Added hIO.Remove, I'll add some more stuff and push the new module.
[editline]08:40AM[/editline]
Added hIO.MakeDirectory( directory )
[editline]08:59AM[/editline]
Added hIO.RemoveDirectory( directory )
[editline]09:03AM[/editline]
Fixed hIO.Write not checking if both arguments are strings.
[editline]09:14AM[/editline]
Added hIO.Rename( oldname, newname )
[editline]09:17AM[/editline]
Thread updated and latest gm_hio pushed. :v:
[editline]09:35AM[/editline]
Uh oh.. hIO.Write doesn't write to partitions. :byodood:
OMFG VIRUSES RUUUUUUUUUN
Serious business, this doesn't look to bad. It has a point, unlike some other projects you've been doing.
*cough*ResourceSmart*cough*
It's nice, maybe add reading/writing file infos.
File/Dir exists functions would be also nice.
And does it also automatically create the directory if you crate a file in a directory that doesn't exists?
Something like listFiles and listDirectories would also be nice.
Added hIO.FileExists( file ). I'll add the rest of the stuff you guys suggested before putting up the latest dll.
[editline]06:42PM[/editline]
Added hIO.DirExists( dir )
[editline]06:59PM[/editline]
Added hIO.Size( file )
[editline]07:24PM[/editline]
Thread and download links updated.
Ok this module is now useful.
Nice.
:worship:
[QUOTE=Helix Alioth;23399231]gm_hio is basically a compact gm_rawio. It's only 13 kb, whereas gm_rawio is 56 kb.[/QUOTE]
I smell MSVC
[editline]07:05PM[/editline]
Yep, MSVC :(
Please compile without msvc deps, it's horrible to install them on WINE (or get them to work too)
Looks good otherwise, though. :)
I'm thinking about making an object-oriented version of this that uses IFileSystem. Does anyone think thats necessary?
[QUOTE=Helix Alioth;23725526]I'm thinking about making an object-oriented version of this that uses IFileSystem. Does anyone think thats necessary?[/QUOTE]
IFileSystem is a bitch sometimes :v:
If you could make it multi threaded, and make it write data/read data to/from a pointer instead of a Lua string (so you could use it with gm_heap) that would be pretty cool.
[QUOTE=Python1320;25070316]Reuploaded: [url]http://g3.iriz.org/~srcds/modules[/url][/QUOTE]
And the source?
I've tried to find it but seems I don't have it any longer
[url=http://solidfiles.com/d/9e38/]Here you go[/url]
[QUOTE=Spacetech;25088364][url=http://solidfiles.com/d/9e38/]Here you go[/url][/QUOTE]
Thanks. This might (seems to) port relatively easy to Linux. Gotta try at some point if no one else is doing that.
It seems to be a waste of time to use anything other than IFileSystem. You guys should just be expanding on file, not creating new libraries.
I need help, fast.
[code] [gamemodes\gmodracer\gamemode\player_methods.lua:145] attempt to index global 'hIO' (a nil value)(Hook: Think)
[/code]Line 145..
[code] hIO.Write("scripts\\vehicles\\gmracer_" .. GAMEMODE.NumJeepsPlaced .. ".txt", SaveFile);[/code]
[QUOTE=343N;25190817]I need help, fast.
[code] [gamemodes\gmodracer\gamemode\player_methods.lua:145] attempt to index global 'hIO' (a nil value)(Hook: Think)
[/code]Line 145..
[code] hIO.Write("scripts\\vehicles\\gmracer_" .. GAMEMODE.NumJeepsPlaced .. ".txt", SaveFile);[/code][/QUOTE]
hIO is not loaded
It is, it errors when it is also loaded using lua_run...
If it wasn't loaded, the line that uses HIO before it (hIO.MakeDirectory) would error.
It can't be loaded.
[editline]05:31PM[/editline]
'hIO' (a nil value)(Hook: Think)
Why are you doing that in a think hook
I cant write into the lua directory?
[editline]09:14PM[/editline]
automerge fail
Has anyone had a chance to remake this for Linux? It would be very useful to myself and a few others.
Sorry, you need to Log In to post a reply to this thread.