Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: function to create/delete/take list directory contents of folder  (Read 8975 times)

0 Members and 1 Guest are viewing this topic.

owl721

  • Newbie
  • *
  • Posts: 10
    • View Profile
function to create/delete/take list directory contents of folder
« on: February 08, 2016, 06:08:20 pm »
it would be useful to manage files. I think it will make game more portable(find save files and etc).

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: function to create/delete/take list directory contents of folder
« Reply #1 on: February 08, 2016, 06:27:57 pm »
Yes, that would be very useful. However, if we want a really robust and well design API for that in SFML, it will take considerable time and effort. If we are pragmatic about this, we should not do it at all.

Why? Well, many libraries already do it. I'm pretty sure boost has something for that. Also, with C++17, there will be a standard filesystem API. By the time we implement something in SFML, this would already be available to most users.
SFML / OS X developer

owl721

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: function to create/delete/take list directory contents of folder
« Reply #2 on: February 08, 2016, 06:30:43 pm »
Hiura, thank for information

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: function to create/delete/take list directory contents of folder
« Reply #3 on: February 08, 2016, 07:58:00 pm »
See also: Contribution Guidelines
Quote
Contributions must fit into one of the following SFML modules: [...] That clearly rules out anything specifically related to game development. Such counterexamples are: Physics, collision detection/response, AI, path finding, 3D abstraction layer (like the current graphics module), file system, etc.

Just use Boost.Filesystem, it's a really good library.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: function to create/delete/take list directory contents of folder
« Reply #4 on: February 09, 2016, 08:55:41 am »
But Boost as a whole is still a horrible dependency IMO. :D

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: function to create/delete/take list directory contents of folder
« Reply #5 on: February 11, 2016, 07:19:47 pm »
So go with Cereal. It's similar to Boost.FileSystem but it's header only and does not come with Boost dependancy.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: function to create/delete/take list directory contents of folder
« Reply #6 on: February 11, 2016, 10:06:51 pm »
Cereal is a serialization library, right? That's nothing like Boost.Filesystem, that's like Boost.Serialization. That's not what he asked for.

But making your own isn't too much work if you don't want to use Boost.

For example, Vittoreo Romeo has one in his Utils library: https://github.com/SuperV1234/SSVUtils

I made my own once, though it does not have OSX support because I don't have OSX to try it with: https://github.com/dabbertorres/gfs

Or you can use something like PhysFS (https://icculus.org/physfs/) with a virtual filesystem.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: function to create/delete/take list directory contents of folder
« Reply #7 on: February 12, 2016, 02:13:28 am »
Oh wow, was I sleeping or what? Yeah you're right. My bad.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: function to create/delete/take list directory contents of folder
« Reply #8 on: February 12, 2016, 06:21:47 pm »
Haha, I figured it was just a mistake! I just wanted to clear things up, just in case. :)

fer_t

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: function to create/delete/take list directory contents of folder
« Reply #9 on: February 22, 2016, 01:47:49 am »
Using POSIX and Windows API a filesystem abstraction is not that hard, a simple one could look like this:

Base class (.cpp)
Base class (.h)
Windows implementation
Unix implementation


Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: function to create/delete/take list directory contents of folder
« Reply #10 on: February 22, 2016, 10:55:35 am »
@fer_t: the implementation you showed provides a tiny fraction of the features of other filesystem libraries, and it's still less portable. One would end up re-implementing a lot from scratch, which somehow misses the point...

There are of course valid reasons for one or the other filesystem library, but not choosing Boost.Filesystem just because it's Boost might not be the best reason. At least exising solutions (also PhysFS) are well-tested, widely known and portable. With Boost, you can already get used to an API that will become part of the standard, probably with only few changes.

And of course it's another component in your game for which you don't have to spend time for development and maintenance...
« Last Edit: February 22, 2016, 10:57:40 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

fer_t

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Re: function to create/delete/take list directory contents of folder
« Reply #11 on: February 22, 2016, 11:28:09 am »
@Nexus I know that was a quick solution, I personally wait for C++17 (I already use C++14 functions in many projects, the only problem is the bad compiler support, at least if your users / devs use msvc), because I try to reduce dependencies.
And the linked "solution" is not designed to be used as a library, is simply a solution for the problem I had in that project, I only wanted to show that it is not that hard.

But you made a point: If you use a 3rd party library you save time.

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: function to create/delete/take list directory contents of folder
« Reply #12 on: February 22, 2016, 05:16:59 pm »
Using POSIX and Windows API a filesystem abstraction is not that hard, a simple one could look like this:

Base class (.cpp)
Base class (.h)
Windows implementation
Unix implementation

I am nowhere near the level of C++ of anyone else on this forum,
there are tons of stuff I don't know

so I have a question about this code

in this file
http://git.os-sc.org/TILES.git/tree/include/filesystem_windows.h

in the function
inline const char* platform_getHome()

there is this line
strcat(home, path)

is that a bug ?
is this even possible ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: function to create/delete/take list directory contents of folder
« Reply #13 on: February 23, 2016, 12:06:17 am »
Why should it be a bug? Here is the reference for that function.

I'm not sure what getenv guarantees, but it might be better anyways to use strncat (if possible). For me personally that looks too much like C and I'd rather stick with boost or similar.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: function to create/delete/take list directory contents of folder
« Reply #14 on: February 23, 2016, 12:42:12 am »
Why should it be a bug? Here is the reference for that function.

I'm not sure what getenv guarantees...

yeah, the amount of memory returned by getenv is what I wondered about

specifically I was wondering about this (from the link you provided)
The behavior is undefined if the destination array is not large enough for the contents of both src and dest and the terminating null character.