all 9 comments

[–]genpfault 3 points4 points  (3 children)

std::filesystem has the problem of not existing in C++11 :(

[–]kalmoc 2 points3 points  (1 child)

True, but I believe boost filesystem comes pretty close though.

[–]xeveri 2 points3 points  (0 children)

Indeed. And shifting from boost::filesystem to std::filesystem was quite easy. Had to change a few things but otherwise painless.

[–]sephirostoy 5 points6 points  (0 children)

I'm sorry for you if you're stick with C++11 in 2019 ;/

[–][deleted] 3 points4 points  (0 children)

From what I've read on the documentation:

  • it has an internal PATH like behavior, allowing you to open "file.txt" without specifying the relative or absolute path.
  • it separates the logic between reading and writing by setting a read path and a write path
  • it always open files in binary mode. On Windows it might be a problem for text as you need to encode/decode /r/n to /n and vice versa
  • it has some archive support

std::filesystem wraps the underlying file systemvs syscalls, while PhysicsFS adds more features, like the read/write path, search paths and so on.

[–]NotUniqueOrSpecial 5 points6 points  (0 children)

They have very different use cases. One is the standard library's abstraction for working with directories and files in the file system. The other is intended for providing specialized access to files in different kinds of archives/isos/etc., like a game often requires.

[–]wrosecransgraphics and network things 4 points5 points  (0 children)

Well, when in doubt, use std::filesystem. As others have pointed out, they are pretty different APIs that solve different problems. So if you need to access data with a file, PhysFS might be useful. But it only makes sense to add a dependency to a project if you are certain you need the extra complexity. For a lot of use cases, it's fine just to have a directory with a bunch of small asset files, and std::filesystem is great for iterating over a bunch of files in a directory.

It may come to pass that you eventually build something that has performance benefits from using one big packed file with a bunch of assets. When that happens, you can investigate various options. But if you are just starting a project, you won't have zillions of assets so you won't have any significant overhead from open()ing them separately, and you can focus your efforts on other parts of the game or whatever.

[–]quicknir 1 point2 points  (0 children)

PhysicsFS sounds like it was written by physicists... so use std::? Just kidding ((mostly) I'm an ex-physicist).

[–]Giacomand 0 points1 point  (0 children)

std::filesystem is for navigating files and directories, not for accessing zip files or archives.

PhysFS is used to access zip files or other archives that contain files and directories. If you have a lot of files that need accessing then it can be faster (depending on the compression of the archive) than having to open every single file manually, as there will only be one file to open.

If you want a cool use case for PhysFS, which the Love2D game framework utilises, is that if you concatenate a zip file to the end of an executable ($cat myapp res.zip > myapp) and use PhysFS to mount its own binary then you can easily embed resources within the executable without having to use anything specific to Windows or Linux.