Skip to content

Commit

Permalink
util: Minor cleanup (#34)
Browse files Browse the repository at this point in the history
Avoid double // in paths
Replace magic 0 value with libzip's ZIP_LENGTH_TO_END
Correct png to image (can be svg as well)
  • Loading branch information
SoSeDiK authored Apr 12, 2024
1 parent d41e8ac commit 92af141
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hyprcursor-util/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static std::optional<std::string> createCursorThemeFromPath(const std::string& p

const std::string THEMENAME = manifest.parsedData.name;

std::string out = (out_.empty() ? path.substr(0, path.find_last_of('/') + 1) : out_) + "/theme_" + THEMENAME + "/";
std::string out = (out_.empty() ? path.substr(0, path.find_last_of('/')) : out_) + "/theme_" + THEMENAME;

const std::string CURSORSSUBDIR = manifest.parsedData.cursorsDirectory;
const std::string CURSORDIR = path + "/" + CURSORSSUBDIR;
Expand Down Expand Up @@ -182,17 +182,17 @@ static std::optional<std::string> createCursorThemeFromPath(const std::string& p

// add meta.hl
const auto METADIR = std::filesystem::exists(CURRENTCURSORSDIR + "/meta.hl") ? (CURRENTCURSORSDIR + "/meta.hl") : (CURRENTCURSORSDIR + "/meta.toml");
zip_source_t* meta = zip_source_file(zip, METADIR.c_str(), 0, 0);
zip_source_t* meta = zip_source_file(zip, METADIR.c_str(), 0, ZIP_LENGTH_TO_END);
if (!meta)
return "(1) failed to add meta " + METADIR + " to hlc";
if (zip_file_add(zip, (std::string{"meta."} + (METADIR.ends_with(".hl") ? "hl" : "toml")).c_str(), meta, ZIP_FL_ENC_UTF_8) < 0)
return "(2) failed to add meta " + METADIR + " to hlc";

meta = nullptr;

// add each cursor png
// add each cursor image
for (auto& i : shape->images) {
zip_source_t* image = zip_source_file(zip, (CURRENTCURSORSDIR + "/" + i.filename).c_str(), 0, 0);
zip_source_t* image = zip_source_file(zip, (CURRENTCURSORSDIR + "/" + i.filename).c_str(), 0, ZIP_LENGTH_TO_END);
if (!image)
return "(1) failed to add image " + (CURRENTCURSORSDIR + "/" + i.filename) + " to hlc";
if (zip_file_add(zip, (i.filename).c_str(), image, ZIP_FL_ENC_UTF_8) < 0)
Expand Down

0 comments on commit 92af141

Please sign in to comment.