2010-09-26 05:09:31 +00:00
|
|
|
#ifndef NALL_DIRECTORY_HPP
|
|
|
|
#define NALL_DIRECTORY_HPP
|
|
|
|
|
2012-08-16 10:30:47 +00:00
|
|
|
#include <nall/file.hpp>
|
2011-09-29 12:08:22 +00:00
|
|
|
#include <nall/intrinsics.hpp>
|
2010-09-26 05:09:31 +00:00
|
|
|
#include <nall/sort.hpp>
|
|
|
|
#include <nall/string.hpp>
|
2011-09-27 11:55:02 +00:00
|
|
|
#include <nall/vector.hpp>
|
2010-09-26 05:09:31 +00:00
|
|
|
|
2011-09-29 12:08:22 +00:00
|
|
|
#if defined(PLATFORM_WINDOWS)
|
2011-08-06 14:03:52 +00:00
|
|
|
#include <nall/windows/utf8.hpp>
|
2010-09-26 05:09:31 +00:00
|
|
|
#else
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
struct directory {
|
2013-05-02 11:25:45 +00:00
|
|
|
static bool create(const string& pathname, unsigned permissions = 0755); //recursive
|
|
|
|
static bool remove(const string& pathname); //recursive
|
|
|
|
static bool exists(const string& pathname);
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring folders(const string& pathname, const string& pattern = "*") {
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
lstring folders = directory::ufolders(pathname, pattern);
|
|
|
|
folders.sort();
|
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring files(const string& pathname, const string& pattern = "*") {
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
lstring files = directory::ufiles(pathname, pattern);
|
|
|
|
files.sort();
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring contents(const string& pathname, const string& pattern = "*") {
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
lstring folders = directory::ufolders(pathname); //pattern search of contents should only filter files
|
|
|
|
lstring files = directory::ufiles(pathname, pattern);
|
|
|
|
folders.sort();
|
|
|
|
files.sort();
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& file : files) folders.append(file);
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring ifolders(const string& pathname, const string& pattern = "*") {
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
lstring folders = ufolders(pathname, pattern);
|
|
|
|
folders.isort();
|
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring ifiles(const string& pathname, const string& pattern = "*") {
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
lstring files = ufiles(pathname, pattern);
|
|
|
|
files.isort();
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring icontents(const string& pathname, const string& pattern = "*") {
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
lstring folders = directory::ufolders(pathname); //pattern search of contents should only filter files
|
|
|
|
lstring files = directory::ufiles(pathname, pattern);
|
|
|
|
folders.isort();
|
|
|
|
files.isort();
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& file : files) folders.append(file);
|
Update to higan v091r14 and ananke v00r03 releases.
byuu says:
higan changelog:
- generates title displayed in emulator window by asking the core
- core builds title solely from "information/title" ... if it's not
there, you don't get a title at all
- sub-system load menu is gone ... since there are multiple revisions of
the SGB, this never really worked well anyway
- to load an SGB, BS-X or ST cartridge, load the base cartridge first
- "File->Load Game" moved to "Load->Import Game" ... may cause a bit of
confusion to new users, but I don't like having a single-item menu,
we'll just have to explain it to new users
- browser window redone to look like ananke
- home button here goes to ~/Emulation rather than just ~ like ananke,
since this is the home of game folders
- game folder icon is now the executable icon for the Tango theme
(orange diamond), meant to represent a complete game rather than
a game file or archive
ananke changelog:
- outputs GBC games to "Game Boy Color/" instead of "Game Boy/"
- adds the file basename to "information/title"
Known issues:
- using ananke to load a GB game trips the Super Famicom SGB mode and
fails (need to make the full-path auto-detection ignore non-bootable
systems)
- need to dump and test some BS-X media before releasing
- ananke lacks BS-X Satellaview cartridge support
- v092 isn't going to let you retarget the ananke/higan game folder path
of ~/Emulation, you will have to wait for a future version if that
bothers you so greatly
[Later, after the v092 release, byuu posted this additional changelog:
- kill laevateinn
- add title()
- add bootable, remove load
- combine file, library
- combine [][][] paths
- fix SFC subtype handling XML->BML
- update file browser to use buttons
- update file browser keyboard handling
- update system XML->BML
- fix sufami turbo hashing
- remove Cartridge::manifest
]
2012-12-25 05:31:55 +00:00
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
//internal functions; these return unsorted lists
|
2013-05-02 11:25:45 +00:00
|
|
|
static lstring ufolders(const string& pathname, const string& pattern = "*");
|
|
|
|
static lstring ufiles(const string& pathname, const string& pattern = "*");
|
2010-09-26 05:09:31 +00:00
|
|
|
};
|
|
|
|
|
2011-09-29 12:08:22 +00:00
|
|
|
#if defined(PLATFORM_WINDOWS)
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool directory::create(const string& pathname, unsigned permissions) {
|
2012-08-16 10:30:47 +00:00
|
|
|
string path;
|
|
|
|
lstring list = string{pathname}.transform("\\", "/").rtrim<1>("/").split("/");
|
|
|
|
bool result = true;
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& part : list) {
|
2012-08-16 10:30:47 +00:00
|
|
|
path.append(part, "/");
|
|
|
|
result &= (_wmkdir(utf16_t(path)) == 0);
|
2012-06-18 10:13:51 +00:00
|
|
|
}
|
|
|
|
return result;
|
Update to v088r14 release.
byuu says:
Changelog:
- added NSS DIP switch settings window (when loading NSS carts with
appropriate manifest.xml file)
- added video shader selection (they go in ~/.config/bsnes/Video
Shaders/ now)
- added driver selection
- added timing settings (not only allows video/audio settings, also has
code to dynamically compute the values for you ... and it actually
works pretty good!)
- moved "None" controller device to bottom of list (it is the least
likely to be used, after all)
- added Interface::path() to support MSU1, USART, Link
- input and hotkey mappings remember list position after assignment
- and more!
target-ethos now has all of the functionality of target-ui, and more.
Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui).
A ~67% reduction in code size, yet it does even more! And you can add or
remove an entire system with only three lines of code (Makefile include,
header include, interface append.)
The only problem left is that the BS-X BIOS won't load the BS Zelda no
Densetsu file.
I can't figure out why it's not working, would appreciate any
assistance, but otherwise I'm probably just going to leave it broken for
v089, sorry.
So the show stoppers for a new release at this point are:
- fix laevateinn to compile with the new interface changes (shouldn't be
too hard, it'll still use the old, direct interface.)
- clean up Emulator::Interface as much as possible (trim down
Information, mediaRequest should use an alternate struct designed to
load firmware / slots separately)
- enhance purify to strip SNES ROM headers, and it really needs a GUI
interface
- it would be highly desirable to make a launcher that can create
a cartridge folder from an existing ROM set (* ethos will need to
accept command-line arguments for this.)
- probably need to remember which controller was selected in each port
for each system across runs
- need to fix the cursor for Super Scope / Justifier games (move from
19-bit to 32-bit colors broke it)
- have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool directory::remove(const string& pathname) {
|
2012-08-16 10:30:47 +00:00
|
|
|
lstring list = directory::contents(pathname);
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& name : list) {
|
2013-12-07 09:12:37 +00:00
|
|
|
if(name.endsWith("/")) directory::remove({pathname, name});
|
2012-08-16 10:30:47 +00:00
|
|
|
else file::remove({pathname, name});
|
|
|
|
}
|
Update to v088r14 release.
byuu says:
Changelog:
- added NSS DIP switch settings window (when loading NSS carts with
appropriate manifest.xml file)
- added video shader selection (they go in ~/.config/bsnes/Video
Shaders/ now)
- added driver selection
- added timing settings (not only allows video/audio settings, also has
code to dynamically compute the values for you ... and it actually
works pretty good!)
- moved "None" controller device to bottom of list (it is the least
likely to be used, after all)
- added Interface::path() to support MSU1, USART, Link
- input and hotkey mappings remember list position after assignment
- and more!
target-ethos now has all of the functionality of target-ui, and more.
Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui).
A ~67% reduction in code size, yet it does even more! And you can add or
remove an entire system with only three lines of code (Makefile include,
header include, interface append.)
The only problem left is that the BS-X BIOS won't load the BS Zelda no
Densetsu file.
I can't figure out why it's not working, would appreciate any
assistance, but otherwise I'm probably just going to leave it broken for
v089, sorry.
So the show stoppers for a new release at this point are:
- fix laevateinn to compile with the new interface changes (shouldn't be
too hard, it'll still use the old, direct interface.)
- clean up Emulator::Interface as much as possible (trim down
Information, mediaRequest should use an alternate struct designed to
load firmware / slots separately)
- enhance purify to strip SNES ROM headers, and it really needs a GUI
interface
- it would be highly desirable to make a launcher that can create
a cartridge folder from an existing ROM set (* ethos will need to
accept command-line arguments for this.)
- probably need to remember which controller was selected in each port
for each system across runs
- need to fix the cursor for Super Scope / Justifier games (move from
19-bit to 32-bit colors broke it)
- have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
|
|
|
return _wrmdir(utf16_t(pathname)) == 0;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool directory::exists(const string& pathname) {
|
2012-06-25 12:49:39 +00:00
|
|
|
string name = pathname;
|
|
|
|
name.trim<1>("\"");
|
|
|
|
DWORD result = GetFileAttributes(utf16_t(name));
|
2010-10-23 05:08:05 +00:00
|
|
|
if(result == INVALID_FILE_ATTRIBUTES) return false;
|
|
|
|
return (result & FILE_ATTRIBUTE_DIRECTORY);
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline lstring directory::ufolders(const string& pathname, const string& pattern) {
|
2010-09-26 05:09:31 +00:00
|
|
|
lstring list;
|
|
|
|
string path = pathname;
|
|
|
|
path.transform("/", "\\");
|
|
|
|
if(!strend(path, "\\")) path.append("\\");
|
|
|
|
path.append("*");
|
|
|
|
HANDLE handle;
|
|
|
|
WIN32_FIND_DATA data;
|
|
|
|
handle = FindFirstFile(utf16_t(path), &data);
|
|
|
|
if(handle != INVALID_HANDLE_VALUE) {
|
|
|
|
if(wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..")) {
|
|
|
|
if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
2011-03-17 12:49:46 +00:00
|
|
|
string name = (const char*)utf8_t(data.cFileName);
|
2013-07-29 09:42:45 +00:00
|
|
|
if(name.match(pattern)) list.append(name);
|
2010-09-26 05:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while(FindNextFile(handle, &data) != false) {
|
|
|
|
if(wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..")) {
|
|
|
|
if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
2011-03-17 12:49:46 +00:00
|
|
|
string name = (const char*)utf8_t(data.cFileName);
|
2013-07-29 09:42:45 +00:00
|
|
|
if(name.match(pattern)) list.append(name);
|
2010-09-26 05:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FindClose(handle);
|
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& name : list) name.append("/"); //must append after sorting
|
2010-09-26 05:09:31 +00:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline lstring directory::ufiles(const string& pathname, const string& pattern) {
|
2010-09-26 05:09:31 +00:00
|
|
|
lstring list;
|
|
|
|
string path = pathname;
|
|
|
|
path.transform("/", "\\");
|
|
|
|
if(!strend(path, "\\")) path.append("\\");
|
|
|
|
path.append("*");
|
|
|
|
HANDLE handle;
|
|
|
|
WIN32_FIND_DATA data;
|
|
|
|
handle = FindFirstFile(utf16_t(path), &data);
|
|
|
|
if(handle != INVALID_HANDLE_VALUE) {
|
|
|
|
if((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
|
2011-03-17 12:49:46 +00:00
|
|
|
string name = (const char*)utf8_t(data.cFileName);
|
2013-07-29 09:42:45 +00:00
|
|
|
if(name.match(pattern)) list.append(name);
|
2010-09-26 05:09:31 +00:00
|
|
|
}
|
|
|
|
while(FindNextFile(handle, &data) != false) {
|
|
|
|
if((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
|
2011-03-17 12:49:46 +00:00
|
|
|
string name = (const char*)utf8_t(data.cFileName);
|
2013-07-29 09:42:45 +00:00
|
|
|
if(name.match(pattern)) list.append(name);
|
2010-09-26 05:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FindClose(handle);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
#else
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool directory::create(const string& pathname, unsigned permissions) {
|
2012-08-16 10:30:47 +00:00
|
|
|
string path;
|
|
|
|
lstring list = string{pathname}.rtrim<1>("/").split("/");
|
|
|
|
bool result = true;
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& part : list) {
|
2012-06-18 10:13:51 +00:00
|
|
|
path.append(part, "/");
|
2012-08-16 10:30:47 +00:00
|
|
|
result &= (mkdir(path, permissions) == 0);
|
2012-06-18 10:13:51 +00:00
|
|
|
}
|
2012-08-16 10:30:47 +00:00
|
|
|
return result;
|
Update to v088r14 release.
byuu says:
Changelog:
- added NSS DIP switch settings window (when loading NSS carts with
appropriate manifest.xml file)
- added video shader selection (they go in ~/.config/bsnes/Video
Shaders/ now)
- added driver selection
- added timing settings (not only allows video/audio settings, also has
code to dynamically compute the values for you ... and it actually
works pretty good!)
- moved "None" controller device to bottom of list (it is the least
likely to be used, after all)
- added Interface::path() to support MSU1, USART, Link
- input and hotkey mappings remember list position after assignment
- and more!
target-ethos now has all of the functionality of target-ui, and more.
Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui).
A ~67% reduction in code size, yet it does even more! And you can add or
remove an entire system with only three lines of code (Makefile include,
header include, interface append.)
The only problem left is that the BS-X BIOS won't load the BS Zelda no
Densetsu file.
I can't figure out why it's not working, would appreciate any
assistance, but otherwise I'm probably just going to leave it broken for
v089, sorry.
So the show stoppers for a new release at this point are:
- fix laevateinn to compile with the new interface changes (shouldn't be
too hard, it'll still use the old, direct interface.)
- clean up Emulator::Interface as much as possible (trim down
Information, mediaRequest should use an alternate struct designed to
load firmware / slots separately)
- enhance purify to strip SNES ROM headers, and it really needs a GUI
interface
- it would be highly desirable to make a launcher that can create
a cartridge folder from an existing ROM set (* ethos will need to
accept command-line arguments for this.)
- probably need to remember which controller was selected in each port
for each system across runs
- need to fix the cursor for Super Scope / Justifier games (move from
19-bit to 32-bit colors broke it)
- have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool directory::remove(const string& pathname) {
|
2012-08-16 10:30:47 +00:00
|
|
|
lstring list = directory::contents(pathname);
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& name : list) {
|
2013-12-03 10:01:59 +00:00
|
|
|
if(name.endsWith("/")) directory::remove({pathname, name});
|
2012-08-16 10:30:47 +00:00
|
|
|
else file::remove({pathname, name});
|
|
|
|
}
|
Update to v088r14 release.
byuu says:
Changelog:
- added NSS DIP switch settings window (when loading NSS carts with
appropriate manifest.xml file)
- added video shader selection (they go in ~/.config/bsnes/Video
Shaders/ now)
- added driver selection
- added timing settings (not only allows video/audio settings, also has
code to dynamically compute the values for you ... and it actually
works pretty good!)
- moved "None" controller device to bottom of list (it is the least
likely to be used, after all)
- added Interface::path() to support MSU1, USART, Link
- input and hotkey mappings remember list position after assignment
- and more!
target-ethos now has all of the functionality of target-ui, and more.
Final code size for the port is 101.2KB (ethos) vs 167.6KB (ui).
A ~67% reduction in code size, yet it does even more! And you can add or
remove an entire system with only three lines of code (Makefile include,
header include, interface append.)
The only problem left is that the BS-X BIOS won't load the BS Zelda no
Densetsu file.
I can't figure out why it's not working, would appreciate any
assistance, but otherwise I'm probably just going to leave it broken for
v089, sorry.
So the show stoppers for a new release at this point are:
- fix laevateinn to compile with the new interface changes (shouldn't be
too hard, it'll still use the old, direct interface.)
- clean up Emulator::Interface as much as possible (trim down
Information, mediaRequest should use an alternate struct designed to
load firmware / slots separately)
- enhance purify to strip SNES ROM headers, and it really needs a GUI
interface
- it would be highly desirable to make a launcher that can create
a cartridge folder from an existing ROM set (* ethos will need to
accept command-line arguments for this.)
- probably need to remember which controller was selected in each port
for each system across runs
- need to fix the cursor for Super Scope / Justifier games (move from
19-bit to 32-bit colors broke it)
- have to refactor that cache.(hv)offset thing to fix ASP
2012-05-06 23:27:42 +00:00
|
|
|
return rmdir(pathname) == 0;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline bool directory::exists(const string& pathname) {
|
2010-10-23 05:08:05 +00:00
|
|
|
DIR *dp = opendir(pathname);
|
|
|
|
if(!dp) return false;
|
|
|
|
closedir(dp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline lstring directory::ufolders(const string& pathname, const string& pattern) {
|
2010-09-26 05:09:31 +00:00
|
|
|
lstring list;
|
2013-05-02 11:25:45 +00:00
|
|
|
DIR* dp;
|
|
|
|
struct dirent* ep;
|
2010-09-26 05:09:31 +00:00
|
|
|
dp = opendir(pathname);
|
|
|
|
if(dp) {
|
|
|
|
while(ep = readdir(dp)) {
|
|
|
|
if(!strcmp(ep->d_name, ".")) continue;
|
|
|
|
if(!strcmp(ep->d_name, "..")) continue;
|
2013-07-29 09:42:45 +00:00
|
|
|
bool is_directory = ep->d_type & DT_DIR;
|
|
|
|
if(ep->d_type & DT_UNKNOWN) {
|
|
|
|
struct stat sp = {0};
|
|
|
|
stat(string{pathname, ep->d_name}, &sp);
|
|
|
|
is_directory = S_ISDIR(sp.st_mode);
|
|
|
|
}
|
|
|
|
if(is_directory) {
|
|
|
|
if(strmatch(ep->d_name, pattern)) list.append(ep->d_name);
|
Update to v070r14 release.
(there was no r13 release posted to the WIP thread)
byuu says:
- nall/string: trim and split functions now take the limit as a template
parameter for clarity, trim_once variants are removed
- quotable.trim<1>("\""); //remove quotes from string
- cheatcode.split<3>(","); //split up to three times, third one is
a description that may have commas
- foobar.trim(" "); //remove any and all spaces
- nall/string: added wildcard() and iwildcard() functions for pattern
matching
- nall/directory: accepts an optional pattern parameter to perform
wildcard matching
- lstring cartridges = directory::contents(path, "*.sfc");
- some people may prefer directory::contents("/path/to/files/*.sfc"),
but I like not having to build a string when you have the path
separated already
- nall/qt: removed entirely, now resides in bsnes/ui-qt/template; I do
intend to replace the check/radio actions with native Qt versions
later
- bsnes/data: new folder, share the parts that both UIs use; bsnes.ico,
bsnes.png, bsnes.Desktop, cheats.xml; simplify Makefile install target
- Makefile: install target now creates .bsnes folder and copies
cheats.xml there for you
- Makefile: gconftool hack removed, not needed for phoenix, will work
around with Qt later
- will probably make bsnes/Qt read the cheats.xml file externally as
well, as that file makes each profile 1MB bigger when embedded
- as such, will probably make bsnes also look in the binary directory
for that file, so Windows users don't have to copy it to their
userdata folder
2010-10-11 10:39:14 +00:00
|
|
|
}
|
2010-09-26 05:09:31 +00:00
|
|
|
}
|
|
|
|
closedir(dp);
|
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
for(auto& name : list) name.append("/"); //must append after sorting
|
2010-09-26 05:09:31 +00:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
inline lstring directory::ufiles(const string& pathname, const string& pattern) {
|
2010-09-26 05:09:31 +00:00
|
|
|
lstring list;
|
2013-05-02 11:25:45 +00:00
|
|
|
DIR* dp;
|
|
|
|
struct dirent* ep;
|
2010-09-26 05:09:31 +00:00
|
|
|
dp = opendir(pathname);
|
|
|
|
if(dp) {
|
|
|
|
while(ep = readdir(dp)) {
|
|
|
|
if(!strcmp(ep->d_name, ".")) continue;
|
|
|
|
if(!strcmp(ep->d_name, "..")) continue;
|
Update to v070r14 release.
(there was no r13 release posted to the WIP thread)
byuu says:
- nall/string: trim and split functions now take the limit as a template
parameter for clarity, trim_once variants are removed
- quotable.trim<1>("\""); //remove quotes from string
- cheatcode.split<3>(","); //split up to three times, third one is
a description that may have commas
- foobar.trim(" "); //remove any and all spaces
- nall/string: added wildcard() and iwildcard() functions for pattern
matching
- nall/directory: accepts an optional pattern parameter to perform
wildcard matching
- lstring cartridges = directory::contents(path, "*.sfc");
- some people may prefer directory::contents("/path/to/files/*.sfc"),
but I like not having to build a string when you have the path
separated already
- nall/qt: removed entirely, now resides in bsnes/ui-qt/template; I do
intend to replace the check/radio actions with native Qt versions
later
- bsnes/data: new folder, share the parts that both UIs use; bsnes.ico,
bsnes.png, bsnes.Desktop, cheats.xml; simplify Makefile install target
- Makefile: install target now creates .bsnes folder and copies
cheats.xml there for you
- Makefile: gconftool hack removed, not needed for phoenix, will work
around with Qt later
- will probably make bsnes/Qt read the cheats.xml file externally as
well, as that file makes each profile 1MB bigger when embedded
- as such, will probably make bsnes also look in the binary directory
for that file, so Windows users don't have to copy it to their
userdata folder
2010-10-11 10:39:14 +00:00
|
|
|
if((ep->d_type & DT_DIR) == 0) {
|
2013-07-29 09:42:45 +00:00
|
|
|
if(strmatch(ep->d_name, pattern)) list.append(ep->d_name);
|
Update to v070r14 release.
(there was no r13 release posted to the WIP thread)
byuu says:
- nall/string: trim and split functions now take the limit as a template
parameter for clarity, trim_once variants are removed
- quotable.trim<1>("\""); //remove quotes from string
- cheatcode.split<3>(","); //split up to three times, third one is
a description that may have commas
- foobar.trim(" "); //remove any and all spaces
- nall/string: added wildcard() and iwildcard() functions for pattern
matching
- nall/directory: accepts an optional pattern parameter to perform
wildcard matching
- lstring cartridges = directory::contents(path, "*.sfc");
- some people may prefer directory::contents("/path/to/files/*.sfc"),
but I like not having to build a string when you have the path
separated already
- nall/qt: removed entirely, now resides in bsnes/ui-qt/template; I do
intend to replace the check/radio actions with native Qt versions
later
- bsnes/data: new folder, share the parts that both UIs use; bsnes.ico,
bsnes.png, bsnes.Desktop, cheats.xml; simplify Makefile install target
- Makefile: install target now creates .bsnes folder and copies
cheats.xml there for you
- Makefile: gconftool hack removed, not needed for phoenix, will work
around with Qt later
- will probably make bsnes/Qt read the cheats.xml file externally as
well, as that file makes each profile 1MB bigger when embedded
- as such, will probably make bsnes also look in the binary directory
for that file, so Windows users don't have to copy it to their
userdata folder
2010-10-11 10:39:14 +00:00
|
|
|
}
|
2010-09-26 05:09:31 +00:00
|
|
|
}
|
|
|
|
closedir(dp);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|