|
Post by matejmosko on Mar 13, 2010 11:30:38 GMT
Hi, I am using linux Ubuntu 9.10 with locale set to slovak, therefore my Documents folder is in the filesystem tree called Dokumenty, not Documents. In your program the path to Documents is hardcoded to "~/Documents" instead of calling "system documents folder". The result is that it creates an ugly appearing Documents folder in my home directory which I cannot delete cause I would loose all my Seventh sense settings.
The best solution would be to follow linux standards and instead of using Documents folder, store Seventh sense configs in either ~/.seventhsense or in ~/.config/seventhsense Such a solution would not ruin appearance of system folder at all. Thanks a lot, this application is great. I really appreciate your work.
|
|
|
Post by curunauth on Mar 14, 2010 23:53:25 GMT
Agreed on this, actually - I've used a different structure for my documents in Linux for a long while and change the default locations, so hardcoded stuff leaves me with an odd extra folder (or breaks). Given that it is not really a document and shouldn't be moved, I concur with the ~/.seventhsense suggestion.
|
|
|
Post by Dave on Mar 16, 2010 1:49:49 GMT
Since you guys seem to know what you are talking about (and I am not a Linux user), would you please take a look at the code, and post a patch or the needed changes here in this thread?
The only code you need to look at is in the "loader.cpp" file in this function: bool LOADER::start_PHYSFS(GAME * game, const char * argv0)
|
|
|
Post by matejmosko on Mar 21, 2010 22:53:23 GMT
Here is modified function to fit linux needs (I am not a professional, so if somebody has better idea, I am really eager to hear). The only thing I changed is three occurences od path "Documents/Seventh Sense" to ".seventhsense". Please do not change anything to uppercase, it can cause issues in linux.
bool LOADER::start_PHYSFS(GAME * game, const char * argv0) { if (!PHYSFS_init(argv0)) { printf("Couldn't initialize PHYSFS... Unable to access any files. Aborting...\n"); return false; } #ifdef __MACOSX__ if (strstr(argv0, "Contents/MacOS")) { basedir = argv0; basedir = basedir.substr(0, basedir.rfind("MacOS")) + "Resources/"; } else #endif basedir = PHYSFS_getBaseDir(); if (game->diag) printf("Base Directory: %s\n",basedir.c_str());
separator = PHYSFS_getDirSeparator();
#ifdef EDITOR writedir = basedir; if (!PHYSFS_setWriteDir(writedir.c_str())) { printf("Unable to establish writing privileges for the file system.\n" "You cannot save any editing procedures. Unrecoverable error. Aborting.\n"); return false; } writedir = PHYSFS_getUserDir(); writedir += ".seventhsense"; { if (!PHYSFS_addToSearchPath(writedir.c_str(),1)) printf("Unable to add write folder to PHYSFS search path.\n" "This may or may not pose a problem....\n"); } #else /* Write files into the user's directory, not the installation directory */ writedir = PHYSFS_getUserDir(); writedir += ".seventhsense"; if (!PHYSFS_setWriteDir(writedir.c_str()) && (!PHYSFS_setWriteDir(PHYSFS_getUserDir()) || !PHYSFS_mkdir(".seventhsense") || !PHYSFS_setWriteDir(writedir.c_str()))) { printf("Unable to establish writing privileges for the file system.\n" "You might be having problems later - No saving games,preferences, etc.\n"); } else { if (!PHYSFS_addToSearchPath(writedir.c_str(),1)) printf("Unable to add write folder to PHYSFS search path.\n"); } #endif
if (!PHYSFS_addToSearchPath(basedir.c_str(),1)) { printf("Unable to add main folder to PHYSFS search path. Unrecoverable error. Aborting.\n"); return false; }
for (size_t i = 0 ; i < game->book_info.size(); i++) add_book_to_path(game, (int)i); //construct and add the needed file/folder paths
for (size_t i = 0 ; i < game->book_info.size(); i++) { std::stringstream ss, ss2; ss << "fanart" << i + 1; ss2 << basedir << "data" << separator << "fanart" << separator << ss.str() << ".zip"; PHYSFS_mount(ss2.str().c_str(),ss.str().c_str(),1); } //init this at beginning to avoid any problems later. font.get_font_list(); image.get_avatar_list(); if (!game->editing) game->settings.load_profiles(); game->settings.read(settings_file); game->inv_manager.read_items();
////also init the buttonmaker which reads in the names game->bm.load_condition_types(game,condition_type_file.c_str()); game->bm.load_effect_types(game,effect_type_file.c_str()); game->journal.read_from_file();
//now check for ts.dat - it if doesn't exist - create it with noughts if (!PHYSFS_exists("data/misc/ts.dat")) { MY_FILE file = game->loader.file.open_to_write("data/misc/ts.dat"); if (!file.physfs_file) { printf("Unable to write to data folder. Please review folder permissions. Aborting..."); return false; } game->loader.file.write(&file,"0\n0\n0\n0\n0\n"); game->loader.file.close(&file); }
return true; }
|
|
|
Post by curunauth on Mar 22, 2010 6:09:23 GMT
Thanks matejmosko! Your edits look fine to me too.
For migration, the program could check for existing files in the old location if it fails to find them in the new one, but that leads to a "when-to-remove-it" problem -- probably should just make a note in the changelog with instructions to move files or a quick little script. The one below just makes the new directory, moves everything to it, and deletes the old directory if the move succeeded - the tests are just to prevent harmless but confusing error output. I'm too lazy to rewrite them for non-bash shells, everyone has bash anyway:
#!/bin/bash shopt -s nullglob if [[ ! -e "$HOME/.seventhsense" ]] then mkdir "$HOME/.seventhsense" fi if [[ -d "$HOME/Documents/Seventh Sense" ]] then if [[ $(ls -1A "$HOME/Documents/Seventh Sense") ]] then mv "$HOME/Documents/Seventh Sense/*" "$HOME/.seventhsense" fi rmdir "$HOME/Documents/Seventh Sense" fi
|
|
|
Post by matejmosko on Apr 6, 2010 8:43:07 GMT
Very nice. I have totally forgotten about the migration. Thanks for this addition
|
|
|
Post by matejmosko on Apr 6, 2010 19:57:21 GMT
I have encountered a problem. I have changed the path according to above, however when compiled, started, downloaded books, the game cries out the file (for book) is missing. I cannot figure out where else the path is hardcoded, while I am not familiar with the code.
The only output that terminal gives me is:
Big time error! Trying to auto-add an effect type that doesn't exist yet! Big time error! Trying to auto-add a condition type that doesn't exist yet! Big time error! Trying to auto-add an effect type that doesn't exist yet! Big time error! Trying to auto-add a condition type that doesn't exist yet!
It appears right when the program is trying to open the book.
|
|
|
Post by Dave on Apr 7, 2010 4:36:00 GMT
Sounds like a problem with physfs. Make sure you are using the fixed library supplied with seventh sense. The version that comes with most release of linux and mac doesn't play nicely with .7z files...
BTW - the path is not hardcoded anywhere else. That was/is the one place.
|
|
|
Post by curunauth on Apr 8, 2010 3:14:42 GMT
Sounds like a problem with physfs. Make sure you are using the fixed library supplied with seventh sense. The version that comes with most release of linux and mac doesn't play nicely with .7z files... BTW - the path is not hardcoded anywhere else. That was/is the one place. Could there be hard links encoded in the save files?
|
|
|
Post by Dave on Apr 8, 2010 3:25:51 GMT
Could there be hard links encoded in the save files? Nope
|
|
|
Post by Dave on Aug 17, 2010 5:32:30 GMT
This whole mess will be easy to solve with the next release. Anyone who runs on Linux has to compile Seventh Sense from the source anyway, so if you include the preprocessor definition STANDALONE , it will compile with the self-contained folder structure, so that all of your profile info, saved games, downloaded zips, etc. will be contained in the same folder that the program is in.
I hope that helps! (Well, you'll have to wait for the next release... but it's coming soon!)
|
|