Browse Source

Change file extension of plugin packages to .vcvplugin.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
9c5a616eab
3 changed files with 22 additions and 22 deletions
  1. +4
    -3
      src/library.cpp
  2. +6
    -7
      src/plugin.cpp
  3. +12
    -12
      src/system.cpp

+ 4
- 3
src/library.cpp View File

@@ -282,9 +282,10 @@ void syncUpdate(const std::string& slug) {

INFO("Downloading plugin %s v%s for %s", slug.c_str(), update.version.c_str(), APP_ARCH.c_str());

// Download zip
std::string pluginDest = system::join(asset::pluginsPath, slug + ".zip");
if (!network::requestDownload(downloadUrl, pluginDest, &update.progress, cookies)) {
// Download plugin package
std::string packageFilename = slug + "-" + update.version + "-" + APP_ARCH + ".vcvplugin";
std::string packagePath = system::join(asset::pluginsPath, packageFilename);
if (!network::requestDownload(downloadUrl, packagePath, &update.progress, cookies)) {
WARN("Plugin %s download was unsuccessful", slug.c_str());
return;
}


+ 6
- 7
src/plugin.cpp View File

@@ -178,10 +178,13 @@ static void extractPackages(std::string path) {
std::string message;

for (std::string packagePath : system::getEntries(path)) {
if (system::getExtension(packagePath) != ".zip")
if (!system::isFile(packagePath))
continue;
INFO("Extracting package %s", packagePath.c_str());
if (system::getExtension(packagePath) != ".vcvplugin")
continue;

// Extract package
INFO("Extracting package %s", packagePath.c_str());
try {
system::unarchiveToFolder(packagePath, path);
}
@@ -218,11 +221,7 @@ void init() {
loadPlugins(asset::pluginsPath);

// If Fundamental wasn't loaded, copy the bundled Fundamental package and load it
#if defined ARCH_MAC
std::string fundamentalSrc = asset::system("Fundamental.txt");
#else
std::string fundamentalSrc = asset::system("Fundamental.zip");
#endif
std::string fundamentalSrc = asset::system("Fundamental.vcvplugin");
std::string fundamentalDir = system::join(asset::pluginsPath, "Fundamental");
if (!settings::devMode && !getPlugin("Fundamental") && system::isFile(fundamentalSrc)) {
INFO("Extracting bundled Fundamental package");


+ 12
- 12
src/system.cpp View File

@@ -300,7 +300,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath
assert(0 <= compressionLevel && compressionLevel <= 19);
r = archive_write_set_filter_option(a, NULL, "compression-level", std::to_string(compressionLevel).c_str());
if (r < ARCHIVE_OK)
throw Exception(string::f("archiveFolder() could not set filter option: %s", archive_error_string(a)));
throw Exception(string::f("Archiver could not set filter option: %s", archive_error_string(a)));

#if defined ARCH_WIN
r = archive_write_open_filename_w(a, string::U8toU16(archivePath).c_str());
@@ -308,7 +308,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath
r = archive_write_open_filename(a, archivePath.c_str());
#endif
if (r < ARCHIVE_OK)
throw Exception(string::f("archiveFolder() could not open archive %s for writing: %s", archivePath.c_str(), archive_error_string(a)));
throw Exception(string::f("Archiver could not open archive %s for writing: %s", archivePath.c_str(), archive_error_string(a)));
DEFER({archive_write_close(a);});

// Open folder for reading
@@ -320,7 +320,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath
r = archive_read_disk_open(disk, folderPath.c_str());
#endif
if (r < ARCHIVE_OK)
throw Exception(string::f("archiveFolder() could not open folder %s for reading: %s", folderPath.c_str(), archive_error_string(a)));
throw Exception(string::f("Archiver could not open folder %s for reading: %s", folderPath.c_str(), archive_error_string(a)));
DEFER({archive_read_close(a);});

// Iterate folder
@@ -332,7 +332,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath
if (r == ARCHIVE_EOF)
break;
if (r < ARCHIVE_OK)
throw Exception(string::f("archiveFolder() could not get next entry from archive: %s", archive_error_string(disk)));
throw Exception(string::f("Archiver could not get next entry from archive: %s", archive_error_string(disk)));

// Recurse dirs
archive_read_disk_descend(disk);
@@ -355,7 +355,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath
// Write file to archive
r = archive_write_header(a, entry);
if (r < ARCHIVE_OK)
throw Exception(string::f("archiveFolder() could not write entry to archive: %s", archive_error_string(a)));
throw Exception(string::f("Archiver could not write entry to archive: %s", archive_error_string(a)));

// Manually copy data
#if defined ARCH_WIN
@@ -391,7 +391,7 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder
r = archive_read_open_filename(a, archivePath.c_str(), 1 << 14);
#endif
if (r < ARCHIVE_OK)
throw Exception(string::f("unzipToFolder() could not open archive %s: %s", archivePath.c_str(), archive_error_string(a)));
throw Exception(string::f("Unarchiver could not open archive %s: %s", archivePath.c_str(), archive_error_string(a)));
DEFER({archive_read_close(a);});

// Open folder for writing
@@ -409,12 +409,12 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder
if (r == ARCHIVE_EOF)
break;
if (r < ARCHIVE_OK)
throw Exception(string::f("unzipToFolder() could not read entry from archive: %s", archive_error_string(a)));
throw Exception(string::f("Unarchiver could not read entry from archive: %s", archive_error_string(a)));

// Convert relative pathname to absolute based on folderPath
std::string entryPath = archive_entry_pathname(entry);
if (!fs::u8path(entryPath).is_relative())
throw Exception(string::f("unzipToFolder() does not support absolute paths: %s", entryPath.c_str()));
throw Exception(string::f("Unarchiver does not support absolute tar paths: %s", entryPath.c_str()));
entryPath = fs::absolute(fs::u8path(entryPath), fs::u8path(folderPath)).generic_u8string();
#if defined ARCH_WIN
archive_entry_copy_pathname_w(entry, string::U8toU16(entryPath).c_str());
@@ -425,7 +425,7 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder
// Write entry to disk
r = archive_write_header(disk, entry);
if (r < ARCHIVE_OK)
throw Exception(string::f("unzipToFolder() could not write file to folder: %s", archive_error_string(disk)));
throw Exception(string::f("Unarchiver could not write file to folder: %s", archive_error_string(disk)));

// Copy data to file
for (;;) {
@@ -437,18 +437,18 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder
if (r == ARCHIVE_EOF)
break;
if (r < ARCHIVE_OK)
throw Exception(string::f("unzipToFolder() could not read data from archive", archive_error_string(a)));
throw Exception(string::f("Unarchiver could not read data from archive", archive_error_string(a)));

// Write data to file
r = archive_write_data_block(disk, buf, size, offset);
if (r < ARCHIVE_OK)
throw Exception(string::f("unzipToFolder() could not write data to file", archive_error_string(disk)));
throw Exception(string::f("Unarchiver could not write data to file", archive_error_string(disk)));
}

// Close file
r = archive_write_finish_entry(disk);
if (r < ARCHIVE_OK)
throw Exception(string::f("unzipToFolder() could not close file", archive_error_string(disk)));
throw Exception(string::f("Unarchiver could not close file", archive_error_string(disk)));
}
}



Loading…
Cancel
Save