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

Author Topic: Finding script files  (Read 3740 times)

0 Members and 2 Guests are viewing this topic.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
Finding script files
« on: July 28, 2013, 04:47:11 am »
Hi everyone. I have a quick question about file system traversal. Basically, I've created a basic scripting language for my game engine, and I want the game engine to search through a folder and find all the script files. Then, I want to have an option on my main menu to enable/disable the "mod." Do you guys know any good libraries or built in features that can accommodate to this? I heard boost had something similar to this.

Thanks
Current Projects:
Technoport

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Finding script files
« Reply #1 on: July 28, 2013, 09:01:55 am »
I want the game engine to search through a folder and find all the script files.
Boost.Filesystem

Then, I want to have an option on my main menu to enable/disable the "mod."
GUI interface and bool variable
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Finding script files
« Reply #2 on: July 28, 2013, 09:41:16 am »
Boost.Filesystem
God no :( , this is so not meant for games and will just be confuzling to fit in that role.
The games centric filesystem that is greatly portable, based on dooms filesystems, easy to use(everything is UTF-8, the end), safe for malicious scripts(there is NO way to go outside of your games root folder and read or write to rest of the system using it, so after cutting out all fstreams and FILEs, engine is sanitized and no script can be danger to outside world) and makes underlying filesystem completely transparent(no wchar_t on windows nonsense) after initializing is: PhysicsFS. Oh, and it turns zips, 7zips and few 90s games archives(id techs paks, build engine grps etc.) into part of its virtual filesystem tree and makes it so that later added folders and archives will cover up files with same paths from earlier ones so modding, changing, default and user settings etc. are very easy to achieve.
« Last Edit: July 28, 2013, 09:47:50 am by FRex »
Back to C++ gamedev with SFML in May 2023

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Finding script files
« Reply #3 on: July 28, 2013, 10:26:43 am »
God no :( , this is so not meant for games and will just be confuzling to fit in that role.
It is meant for file systems, which are also used in games.

You are right that PhysicsFS has some very specific features for games. But sometimes plain file systems are still required, e.g. when you want to load/save something in any directory. Also, PhysicsFS is C, but it's really well-designed, object-orientated C. And it's great that some archives are embedded; unfortunately it's not possible to encrypt them.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Perde

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: Finding script files
« Reply #4 on: July 28, 2013, 06:04:44 pm »
This is what I was using to solve a similar problem. I didn't see any reason to use a full-blown file system api, just to get the files in a specific directory.

#include <dirent.h>

DIR *dir;
struct dirent *ent;
if ((dir = opendir ("c:\\src\\")) != NULL) {
  /* print all the files and directories within directory */
  while ((ent = readdir (dir)) != NULL) {
    printf ("%s\n", ent->d_name);
  }
  closedir (dir);
} else {
  /* could not open directory */
  perror ("");
  return EXIT_FAILURE;
}

Also happens to be the very first result from a google search on "list files in directory c++".
http://stackoverflow.com/questions/612097/how-can-i-get-a-list-of-files-in-a-directory-using-c-or-c

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Finding script files
« Reply #5 on: July 28, 2013, 06:10:02 pm »
dirent.h is part of posix and isn't always there on windows, it's not there for some visual studios(but there is a separate .h that emulates it)
Back to C++ gamedev with SFML in May 2023

 

anything