Quellcode durchsuchen

Make bundle-dir optional

Daniele Bartolini vor 10 Jahren
Ursprung
Commit
b042f7f62b
2 geänderte Dateien mit 13 neuen und 10 gelöschten Zeilen
  1. 7 1
      src/device/device.cpp
  2. 6 9
      src/device/device_options.cpp

+ 7 - 1
src/device/device.cpp

@@ -350,7 +350,13 @@ void Device::run()
 #if CROWN_PLATFORM_ANDROID
 		_bundle_filesystem = CE_NEW(_allocator, ApkFilesystem)(default_allocator(), const_cast<AAssetManager*>((AAssetManager*)_device_options._asset_manager));
 #else
-		_bundle_filesystem = CE_NEW(_allocator, DiskFilesystem)(default_allocator(), _device_options._bundle_dir);
+		const char* bundle_dir = _device_options._bundle_dir;
+		if (!bundle_dir)
+		{
+			char buf[1024];
+			bundle_dir = os::getcwd(buf, sizeof(buf));
+		}
+		_bundle_filesystem = CE_NEW(_allocator, DiskFilesystem)(default_allocator(), bundle_dir);
 		_last_log = _bundle_filesystem->open(CROWN_LAST_LOG, FileOpenMode::WRITE);
 #endif // CROWN_PLATFORM_ANDROID
 

+ 6 - 9
src/device/device_options.cpp

@@ -76,16 +76,13 @@ int DeviceOptions::parse()
 	}
 
 	_bundle_dir = cl.get_parameter("bundle-dir");
-	if (_bundle_dir == NULL)
+	if (_bundle_dir != NULL)
 	{
-		help("Bundle dir must be specified.");
-		return EXIT_FAILURE;
-	}
-
-	if (!path::is_absolute(_bundle_dir))
-	{
-		help("Bundle dir must be absolute.");
-		return EXIT_FAILURE;
+		if (!path::is_absolute(_bundle_dir))
+		{
+			help("Bundle dir must be absolute.");
+			return EXIT_FAILURE;
+		}
 	}
 
 	_do_compile = cl.has_argument("compile");