projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new editor image for infoblock
[supertux.git]
/
lib
/
app
/
setup.cpp
diff --git
a/lib/app/setup.cpp
b/lib/app/setup.cpp
index
fb41e0f
..
c7972c4
100644
(file)
--- a/
lib/app/setup.cpp
+++ b/
lib/app/setup.cpp
@@
-67,7
+67,7
@@
void seticon(void);
void usage(char * prog, int ret);
/* Does the given file exist and is it accessible? */
void usage(char * prog, int ret);
/* Does the given file exist and is it accessible? */
-
int
FileSystem::faccessible(const std::string& filename)
+
bool
FileSystem::faccessible(const std::string& filename)
{
struct stat filestat;
if (stat(filename.c_str(), &filestat) == -1)
{
struct stat filestat;
if (stat(filename.c_str(), &filestat) == -1)
@@
-84,7
+84,7
@@
int FileSystem::faccessible(const std::string& filename)
}
/* Can we write to this location? */
}
/* Can we write to this location? */
-
int
FileSystem::fwriteable(const std::string& filename)
+
bool
FileSystem::fwriteable(const std::string& filename)
{
FILE* fi;
fi = fopen(filename.c_str(), "wa");
{
FILE* fi;
fi = fopen(filename.c_str(), "wa");
@@
-97,7
+97,7
@@
int FileSystem::fwriteable(const std::string& filename)
}
/* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/
}
/* Makes sure a directory is created in either the SuperTux home directory or the SuperTux base directory.*/
-
int
FileSystem::fcreatedir(const std::string& relative_dir)
+
bool
FileSystem::fcreatedir(const std::string& relative_dir)
{
std::string path = st_dir + "/" + relative_dir + "/";
if(mkdir(path.c_str(),0755) != 0)
{
std::string path = st_dir + "/" + relative_dir + "/";
if(mkdir(path.c_str(),0755) != 0)
@@
-252,6
+252,15
@@
std::set<std::string> FileSystem::dfiles(const std::string& rel_path, const std
return sdirs;
}
return sdirs;
}
+std::string FileSystem::dirname(const std::string& filename)
+{
+ std::string::size_type p = filename.find_last_of('/');
+ if(p == std::string::npos)
+ return "";
+
+ return filename.substr(0, p+1);
+}
+
void Setup::init(const std::string& _package_name,
const std::string& _package_symbol_name,
const std::string& _package_version)
void Setup::init(const std::string& _package_name,
const std::string& _package_symbol_name,
const std::string& _package_version)
@@
-262,6
+271,7
@@
void Setup::init(const std::string& _package_name,
directories();
dictionary_manager.add_directory(datadir + "/locale");
directories();
dictionary_manager.add_directory(datadir + "/locale");
+ dictionary_manager.set_charset("iso8859-1");
}
/* --- SETUP --- */
}
/* --- SETUP --- */
@@
-279,10
+289,9
@@
void Setup::directories()
st_dir = home + "/." + package_symbol_name;
/* Remove .supertux config-file from old SuperTux versions */
st_dir = home + "/." + package_symbol_name;
/* Remove .supertux config-file from old SuperTux versions */
- if(FileSystem::faccessible(st_dir))
- {
- remove(st_dir.c_str());
- }
+ if(FileSystem::faccessible(st_dir)) {
+ remove(st_dir.c_str());
+ }
st_save_dir = st_dir + "/save";
st_save_dir = st_dir + "/save";
@@
-294,8
+303,8
@@
void Setup::directories()
// try current directory as datadir
if(datadir.empty()) {
// try current directory as datadir
if(datadir.empty()) {
-
if(FileSystem::faccessible("./data/intro
.txt"))
- datadir = "./data";
+
if(FileSystem::faccessible("./data/credits
.txt"))
+ datadir = "./data
/
";
}
// User has not that a datadir, so we try some magic
}
// User has not that a datadir, so we try some magic
@@
-313,23
+322,25
@@
void Setup::directories()
{
std::string exedir = std::string(dirname(exe_file)) + "/";
{
std::string exedir = std::string(dirname(exe_file)) + "/";
- datadir = exedir + ".
./data
"; // SuperTux run from source dir
+ datadir = exedir + ".
/data/
"; // SuperTux run from source dir
if (access(datadir.c_str(), F_OK) != 0)
{
if (access(datadir.c_str(), F_OK) != 0)
{
- datadir = exedir + "../../
data
"; //SuperTux run from source dir (with libtool script)
+ datadir = exedir + "../../
../../data/
"; //SuperTux run from source dir (with libtool script)
if (access(datadir.c_str(), F_OK) != 0)
{
if (access(datadir.c_str(), F_OK) != 0)
{
- datadir = exedir + "../share/" + package_symbol_name; // SuperTux run from PATH
+ datadir = exedir + "../share/" + package_symbol_name
+ "/"
; // SuperTux run from PATH
if (access(datadir.c_str(), F_OK) != 0)
{ // If all fails, fall back to compiled path
if (access(datadir.c_str(), F_OK) != 0)
{ // If all fails, fall back to compiled path
- datadir = DATA_PREFIX;
+ datadir = DATA_PREFIX;
+ datadir += "/";
}
}
}
}
#else
}
}
}
}
#else
- datadir = DATA_PREFIX;
+ datadir = DATA_PREFIX;
+ datadir += "/";
#endif
}
printf("Datadir: %s\n", datadir.c_str());
#endif
}
printf("Datadir: %s\n", datadir.c_str());