#include <Cockpit/panel.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
+#include <Main/fg_init.hxx> // for platformDesktopPath
#include <Main/fg_os.hxx>
#include <Viewer/renderer.hxx>
#include <Viewer/viewmgr.hxx>
string dir = fgGetString("/sim/paths/screenshot-dir");
if (dir.empty())
- dir = fgGetString("/sim/fg-current");
+ dir = platformDesktopPath().str();
_path.set(dir + '/');
if (_path.create_dir( 0755 )) {
config.append( "flightgear.org" );
return config;
}
+
+SGPath platformDesktopPath()
+{
+ /*
+ typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
+ static GetSpecialFolderPath SHGetSpecialFolderPath = NULL;
+
+ // lazy open+resolve of shell32
+ if (!SHGetSpecialFolderPath) {
+ HINSTANCE shellDll = ::LoadLibrary("shell32");
+ SHGetSpecialFolderPath = (GetSpecialFolderPath) GetProcAddress(shellDll, "SHGetSpecialFolderPathA");
+ }
+
+ if (!SHGetSpecialFolderPath)
+ return SGPath();
+
+ char path[PATH_MAX];
+ if (SHGetSpecialFolderPath(0, path, CSIDL_DESKTOPDIRECTORY, false)) {
+ return SGPath(path);
+ }
+
+ // failed, bad
+ return SGPath();
+ */
+
+ return SGPath(fgGetString("/sim/fg-current"));
+}
+
#elif __APPLE__
#include <CoreServices/CoreServices.h>
appData.append("FlightGear");
return appData;
}
+
+SGPath platformDesktopPath()
+{
+ FSRef ref;
+ OSErr err = FSFindFolder(kUserDomain, kDesktopFolderType, false, &ref);
+ if (err) {
+ return SGPath();
+ }
+
+ unsigned char path[1024];
+ if (FSRefMakePath(&ref, path, 1024) != noErr) {
+ return SGPath();
+ }
+
+ return SGPath((const char*) path);
+}
+
#else
static SGPath platformDefaultDataPath()
{
config.append( ".fgfs" );
return config;
}
+
+SGPath platformDesktopPath()
+{
+ SGPath config( getenv("HOME") );
+ config.append( "Desktop" );
+ return config;
+}
#endif
void fgInitHome()
#define _FG_INIT_HXX
#include <string>
+#include <simgear/misc/sg_path.hxx>
// forward decls
class SGPropertyNode;
-class SGPath;
// Return the current base package version
std::string fgBasePackageVersion();
// Initialize the localization
SGPropertyNode *fgInitLocale(const char *language);
+/// retrieve the user's desktop directory path
+SGPath platformDesktopPath();
// Init navaids and waypoints
bool fgInitNav ();