diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af79df5..b667ea5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,6 +106,12 @@ target_link_libraries(updatershared tinythread ) +if(APPLE) + find_library(COCOA_LIBRARY Cocoa) + find_library(SECURITY_LIBRARY Security) + target_link_libraries(updatershared ${SECURITY_LIBRARY} ${COCOA_LIBRARY}) +endif() + if (UNIX) target_link_libraries(updatershared pthread dl) endif() @@ -116,13 +122,6 @@ endif() add_executable(updater ${EXE_FLAGS} main.cpp) -if(APPLE) - set_target_properties( - updater - PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa" - ) -endif() - target_link_libraries(updater updatershared ) @@ -133,7 +132,7 @@ endif() install(TARGETS updater RUNTIME DESTINATION bin) -add_executable(zip-tool zip.cpp) +add_executable(zip-tool zip-tool.cpp) target_link_libraries(zip-tool updatershared) diff --git a/src/FileUtils.cpp b/src/FileUtils.cpp index ab06f33..ffad7e2 100644 --- a/src/FileUtils.cpp +++ b/src/FileUtils.cpp @@ -160,7 +160,7 @@ void FileUtils::addToZip(const char* archivePath, const char* path, const char* { throw IOException("Unable to add new file to zip archive"); } - result = zipWriteInFileInZip(archive, content, length); + result = zipWriteInFileInZip(archive, content, static_cast(length)); if (result != ZIP_OK) { throw IOException("Unable to write file data to zip archive"); @@ -536,14 +536,14 @@ void FileUtils::writeFile(const char* path, const char* data, int length) throw stream.write(data,length); } -std::string FileUtils::readFile(const char* path) +std::string FileUtils::readFile(const char* path) throw (IOException) { std::ifstream inputFile(path, std::ios::in | std::ios::binary); std::string content; inputFile.seekg(0, std::ios::end); content.resize(static_cast(inputFile.tellg())); inputFile.seekg(0, std::ios::beg); - inputFile.read(&content[0], content.size()); + inputFile.read(&content[0], static_cast(content.size())); return content; } diff --git a/src/zip.cpp b/src/zip-tool.cpp similarity index 96% rename from src/zip.cpp rename to src/zip-tool.cpp index dd7302f..0da5728 100644 --- a/src/zip.cpp +++ b/src/zip-tool.cpp @@ -56,7 +56,7 @@ int main(int argc, char** argv) std::string path = iter->substr(inputDir.size()+1); std::string content = FileUtils::readFile(iter->c_str()); LOG(Info, "Adding " + path + " to archive " + archivePath); - FileUtils::addToZip(archivePath.c_str(), path.c_str(), content.data(), content.length()); + FileUtils::addToZip(archivePath.c_str(), path.c_str(), content.data(), static_cast(content.length())); } } catch (const std::exception& ex)