Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411279 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 03:32:46 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Simple file/directory access library (abstraction layer)
Pages: [1]
Print
Author Topic: Simple file/directory access library (abstraction layer)  (Read 1137 times)
rivon
Level 10
*****



View Profile
« on: February 23, 2015, 09:53:23 AM »

Hi guys Smiley

I'm in a need of a simple library for accessing and traversing filesystem directories.
It should just have functions for checking the existence of directories and files, listing of files in the directories, creating new files/directories and deleting them. And it should be multiplatform and for C++ (or C).
The only library like this that I know is wxWidgets with it's wxDir class and these functions like wxFile/DirExists, wxRename/Copy/RemoveFile, wxMk/RmDir, wxGetWorkingDirectory etc. I would normally use it but I can't just take a few of these functions and put them in my game. I would have to take the whole library which is just unneccesarily big.

Do you know of any library with this functionality but which would be small, possibly just one header and one source file? Or at least just a small module of some big library that can be used separately and doesn't have too many dependencies.

Thank you.
Logged
ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #1 on: February 23, 2015, 10:17:28 AM »

I've always just used POSIX/stdio APIs for this sort of thing, with wrappers like this for the bits Windows doesn't provide by default.
Logged

Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #2 on: February 23, 2015, 02:53:52 PM »

If you've got the stomach to handle it, Boost has a filesystem library.
Logged
Boreal
Level 6
*


Reinventing the wheel


View Profile
« Reply #3 on: February 23, 2015, 05:35:59 PM »

libuv has a large suite of filesystem handling functions and it's incredibly portable, and also pretty lightweight.
Logged

"In software, the only numbers of significance are 0, 1, and N." - Josh Barczak

magma - Reconstructed Mantle API
oahda
Level 10
*****



View Profile
« Reply #4 on: February 25, 2015, 02:23:53 AM »

I've used dirent.h to much delight in the past. It's standard in UNIX but not in Windows – it seems that someone has fixed that, however.

If you're using SDL (at least SDL 2) as your foundation, there are some great file handling functions in there too, working well on iOS and Android too.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5 on: February 25, 2015, 09:21:44 AM »

Is filesystem still not part of the C++ spec? Even if it isn't I haven't run into any issues using it. It's basically the same as the boost one except you dont have to use boost Smiley
Logged

oahda
Level 10
*****



View Profile
« Reply #6 on: February 25, 2015, 09:43:57 AM »

Oh, did they introduce something besides fstream to the standard? std::thread is like the only new thing I've been keeping up with, and I haven't even been using it yet.
Logged

Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #7 on: February 25, 2015, 01:06:35 PM »

Is filesystem still not part of the C++ spec? Even if it isn't I haven't run into any issues using it. It's basically the same as the boost one except you dont have to use boost Smiley

The filesystem header is a proposed standard, but not yet part of the spec.
https://msdn.microsoft.com/en-us/library/hh874694.aspx
Logged
rivon
Level 10
*****



View Profile
« Reply #8 on: February 28, 2015, 11:44:33 AM »

Thanks for all the suggestions guys. Even though I don't normally like Boost, I will probably use the Boost.filesystem library as it seems quite small and simple.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #9 on: February 28, 2015, 04:14:32 PM »

maybe try to use std::filesystem at first then switch to boost if you hit an incompatibility error. I've been able to use it successfully across a handful of platforms despite it not being standard. The interface should be nearly identical if not totally identical so you could easily switch to boost later if you hit a wall.

IIRC I used the second major version of filesystem (tr2 I think the name was) and there is a newer one in boost. Not sure how much the interface changed.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic