Files
dnf-utils/libnpk/libNPK_Utils.h
T
2025-09-01 20:47:58 +08:00

34 lines
1.3 KiB
C++

#pragma once
#include <string>
// Convert a size in bytes to a human-readable string
std::string sizeToString(int64_t size);
// Convert a size string (e.g., "10k", "5M", "2G") to an integer size in bytes
int64_t sizeFromString(const char* sizeStr);
// Compare two file names, considering both long and short paths
int compareTwoFileName(const char* szFileName1, const char* szFileName2);
// Convert a standard ANSI string to a wide string (UTF-16)
std::wstring convertAnsiStringToWide(const char* szSource);
// Read a file into a buffer and return the buffer pointer.
uint8_t* readFileToBuffer(const char* filename, int64_t& outSize);
// Free the file buffer allocated by readFileToBuffer
void freeFileBuffer(uint8_t* buffer);
// Clears the specified path by deleting all files and optionally removing the directory itself.
bool clearPath(const char* szPath, bool recursion, bool removeSelf);
//Creates an empty directory at the specified path. If the path already exists and is a directory, clears its contents.
bool createEmptyPath(const char* szPath);
// Force create a directory path, ensuring all parent directories are created as needed.
bool forceCreatePath(const char* szPath);
// Get the parent directory path of the specified path.
void getParentPath(char* szPath);