Commit 4debea5f authored by Scarlett Gately Moore's avatar Scarlett Gately Moore

New upstream version 0.1.1

parents
*build*/
cmake-build-*/
.idea/
Testing/
[submodule "lib/gtest"]
path = lib/gtest
url = https://github.com/google/googletest.git
language: c
compiler: gcc
services:
- docker
matrix:
include:
- env:
- ARCH=x86_64
- DOCKER_IMAGE=quay.io/appimage/appimagebuild
- env:
- ARCH=i686
- DOCKER_IMAGE=quay.io/appimage/appimagebuild-i386
- env:
- ARCH=x86_64
addons:
apt:
update: true
packages:
- libfuse-dev
- desktop-file-utils
script:
- bash travis/travis-build.sh
notifications:
irc:
channels:
- "chat.freenode.net#AppImage"
on_success: always # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: always # options: [always|never|change] default: always
template:
- "%{repository} build %{build_number}: %{result} %{build_url}"
use_notice: true
# skip_join: true
cmake_minimum_required(VERSION 3.2)
project(libappimage)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
include(cmake/tools.cmake)
include(cmake/dependencies.cmake)
add_subdirectory(lib)
add_subdirectory(src)
include(CTest)
enable_testing()
add_subdirectory(tests)
# libappimage
# required for PNG imported target
cmake_minimum_required(VERSION 3.0)
find_path(squashfuse_H_DIR
NAMES squashfuse.h
HINTS ${CMAKE_INSTALL_PREFIX}
PATH_SUFFIXES include include/linux
)
if(NOT squashfuse_H_DIR)
message(FATAL_ERROR "squashfuse.h not found")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(squashfuse DEFAULT_MSG SQUASHFUSE_INCLUDE_DIR SQUASHFUSE_LIBRARY_DIR)
add_library(squashfuse IMPORTED SHARED)
set_property(TARGET squashfuse PROPERTY IMPORTED_LOCATION ${squashfuse_LIBRARY})
set_property(TARGET squashfuse PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${squashfuse_H_DIR}")
# >= 3.2 required for ExternalProject_Add_StepDependencies
cmake_minimum_required(VERSION 3.2)
include(${PROJECT_SOURCE_DIR}/cmake/scripts.cmake)
# the names of the targets need to differ from the library filenames
# this is especially an issue with libcairo, where the library is called libcairo
# therefore, all libs imported this way have been prefixed with lib
import_pkgconfig_target(TARGET_NAME libglib PKGCONFIG_TARGET glib-2.0>=2.40)
import_pkgconfig_target(TARGET_NAME libgobject PKGCONFIG_TARGET gobject-2.0>=2.40)
import_pkgconfig_target(TARGET_NAME libgio PKGCONFIG_TARGET gio-2.0>=2.40)
import_pkgconfig_target(TARGET_NAME libzlib PKGCONFIG_TARGET zlib)
import_pkgconfig_target(TARGET_NAME libcairo PKGCONFIG_TARGET cairo)
if(USE_CCACHE)
message(STATUS "Using CCache to build AppImageKit dependencies")
# TODO: find way to use find_program with all possible paths
# (might differ from distro to distro)
# these work on Debian and Ubuntu:
set(CC "/usr/lib/ccache/gcc")
set(CXX "/usr/lib/ccache/g++")
else()
set(CC "${CMAKE_C_COMPILER}")
set(CXX "${CMAKE_CXX_COMPILER}")
endif()
set(CFLAGS ${DEPENDENCIES_CFLAGS})
set(CPPFLAGS ${DEPENDENCIES_CPPFLAGS})
set(LDFLAGS ${DEPENDENCIES_LDFLAGS})
set(USE_SYSTEM_XZ OFF CACHE BOOL "Use system xz/liblzma instead of building our own")
if(NOT USE_SYSTEM_XZ)
message(STATUS "Downloading and building xz")
ExternalProject_Add(xz-EXTERNAL
URL https://netcologne.dl.sourceforge.net/project/lzmautils/xz-5.2.3.tar.gz
URL_HASH SHA512=a5eb4f707cf31579d166a6f95dbac45cf7ea181036d1632b4f123a4072f502f8d57cd6e7d0588f0bf831a07b8fc4065d26589a25c399b95ddcf5f73435163da6
CONFIGURE_COMMAND CC=${CC} CXX=${CXX} CFLAGS=${CFLAGS} CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} <SOURCE_DIR>/configure --with-pic --disable-shared --enable-static --prefix=<INSTALL_DIR> --libdir=<INSTALL_DIR>/lib ${EXTRA_CONFIGURE_FLAGS}
BUILD_COMMAND ${MAKE}
INSTALL_COMMAND ${MAKE} install
)
import_external_project(
TARGET_NAME xz
EXT_PROJECT_NAME xz-EXTERNAL
LIBRARY_DIRS <INSTALL_DIR>/lib/
LIBRARIES "<INSTALL_DIR>/lib/liblzma.a"
INCLUDE_DIRS "<SOURCE_DIR>/src/liblzma/api/"
)
else()
message(STATUS "Using system xz")
import_pkgconfig_target(TARGET_NAME xz PKGCONFIG_TARGET liblzma)
endif()
# as distros don't provide suitable squashfuse and squashfs-tools, those dependencies are bundled in, can, and should
# be used from this repository for AppImageKit
# for distro packaging, it can be linked to an existing package just fine
set(USE_SYSTEM_SQUASHFUSE OFF CACHE BOOL "Use system libsquashfuse instead of building our own")
if(NOT USE_SYSTEM_SQUASHFUSE)
message(STATUS "Downloading and building squashfuse")
# TODO: implement out-of-source builds for squashfuse, as for the other dependencies
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/patches/patch-squashfuse.sh.in
${CMAKE_CURRENT_BINARY_DIR}/patch-squashfuse.sh
@ONLY
)
ExternalProject_Add(squashfuse-EXTERNAL
GIT_REPOSITORY https://github.com/vasi/squashfuse/
GIT_TAG 1f98030
UPDATE_COMMAND "" # make sure CMake won't try to fetch updates unnecessarily and hence rebuild the dependency every time
PATCH_COMMAND bash -xe ${CMAKE_CURRENT_BINARY_DIR}/patch-squashfuse.sh
CONFIGURE_COMMAND ${LIBTOOLIZE} --force
COMMAND env ACLOCAL_FLAGS="-I /usr/share/aclocal" aclocal
COMMAND ${AUTOHEADER}
COMMAND ${AUTOMAKE} --force-missing --add-missing
COMMAND ${AUTORECONF} -fi || true
COMMAND ${SED} -i "/PKG_CHECK_MODULES.*/,/,:./d" configure # https://github.com/vasi/squashfuse/issues/12
COMMAND ${SED} -i "s/typedef off_t sqfs_off_t/typedef int64_t sqfs_off_t/g" common.h # off_t's size might differ, see https://stackoverflow.com/a/9073762
COMMAND CC=${CC} CXX=${CXX} CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} <SOURCE_DIR>/configure --disable-demo --disable-high-level --without-lzo --without-lz4 --prefix=<INSTALL_DIR> --libdir=<INSTALL_DIR>/lib --with-xz=${xz_PREFIX} ${EXTRA_CONFIGURE_FLAGS}
COMMAND ${SED} -i "s|XZ_LIBS = -llzma |XZ_LIBS = -Bstatic ${xz_LIBRARIES}/|g" Makefile
BUILD_COMMAND ${MAKE}
BUILD_IN_SOURCE ON
INSTALL_COMMAND ${MAKE} install
)
import_external_project(
TARGET_NAME squashfuse
EXT_PROJECT_NAME squashfuse-EXTERNAL
LIBRARIES "<SOURCE_DIR>/.libs/libsquashfuse.a;<SOURCE_DIR>/.libs/libsquashfuse_ll.a;<SOURCE_DIR>/.libs/libfuseprivate.a"
INCLUDE_DIRS "<SOURCE_DIR>"
)
else()
message(STATUS "Using system squashfuse")
import_pkgconfig_target(TARGET_NAME squashfuse PKGCONFIG_TARGET squashfuse)
endif()
set(USE_SYSTEM_LIBARCHIVE OFF CACHE BOOL "Use system libarchive instead of building our own")
if(NOT USE_SYSTEM_LIBARCHIVE)
message(STATUS "Downloading and building libarchive")
ExternalProject_Add(libarchive-EXTERNAL
URL https://www.libarchive.org/downloads/libarchive-3.3.1.tar.gz
URL_HASH SHA512=90702b393b6f0943f42438e277b257af45eee4fa82420431f6a4f5f48bb846f2a72c8ff084dc3ee9c87bdf8b57f4d8dddf7814870fe2604fe86c55d8d744c164
CONFIGURE_COMMAND CC=${CC} CXX=${CXX} CFLAGS=${CFLAGS} CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} <SOURCE_DIR>/configure --with-pic --disable-shared --enable-static --disable-bsdtar --disable-bsdcat --disable-bsdcpio --with-zlib --without-bz2lib --without-iconv --without-lz4 --without-lzma --without-lzo2 --without-nettle --without-openssl --without-xml2 --without-expat --prefix=<INSTALL_DIR> --libdir=<INSTALL_DIR>/lib ${EXTRA_CONFIGURE_FLAGS}
BUILD_COMMAND ${MAKE}
INSTALL_COMMAND ${MAKE} install
)
import_external_project(
TARGET_NAME libarchive
EXT_PROJECT_NAME libarchive-EXTERNAL
LIBRARIES "<INSTALL_DIR>/lib/libarchive.a"
INCLUDE_DIRS "<INSTALL_DIR>/include/"
)
else()
message(STATUS "Using system libarchive")
import_find_pkg_target(libarchive LibArchive LibArchive)
endif()
#### build dependency configuration ####
# only have to build custom xz when not using system libxz
if(TARGET xz-EXTERNAL)
if(TARGET squashfuse-EXTERNAL)
ExternalProject_Add_StepDependencies(squashfuse-EXTERNAL configure xz-EXTERNAL)
endif()
endif()
# - Config file for the AppImage package
# It defines the following variables
# LIBAPPIMAGE_INCLUDE_DIRS - include directories for LIBAPPIMAGE
# LIBAPPIMAGE_LIBRARIES - libraries to link against
# Compute paths
get_filename_component(LIBAPPIMAGE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(LIBAPPIMAGE_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
# Our library dependencies (contains definitions for IMPORTED targets)
include("${LIBAPPIMAGE_CMAKE_DIR}/libappimageTargets.cmake")
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GIO REQUIRED gio-2.0)
pkg_check_modules(ZLIB REQUIRED zlib)
pkg_check_modules(CAIRO REQUIRED cairo)
pkg_check_modules(OPENSSL REQUIRED openssl)
find_library(LIBAPPIMAGE_SHARED_PATH
NAMES appimage
HINTS "${CMAKE_PREFIX_PATH}"
)
set(LIBAPPIMAGE_LIBRARIES ${LIBAPPIMAGE_SHARED_PATH})
set(PACKAGE_VERSION "@GIT_COMMIT@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
This diff is collapsed.
if(TOOLS_PREFIX)
message(STATUS "TOOLS_PREFIX ${TOOLS_PREFIX} detected")
endif()
# first of all, make sure required programs are available
function(check_program name)
if(TOOLS_PREFIX)
set(prefix ${TOOLS_PREFIX}_)
endif()
message(STATUS "Checking for program ${name}")
string(TOUPPER ${name} name_upper)
if(prefix)
# try prefixed version first
find_program(${name_upper} ${prefix}${name})
endif()
# try non-prefixed version
if(NOT ${name_upper})
find_program(${name_upper} ${name})
if(NOT ${name_upper})
message(FATAL_ERROR "Could not find required program ${name}.")
endif()
endif()
message(STATUS "Found program ${name}: ${${name_upper}}")
mark_as_advanced(${name_upper})
endfunction()
check_program(aclocal)
check_program(autoheader)
check_program(automake)
check_program(autoreconf)
check_program(libtoolize)
check_program(patch)
check_program(sed)
check_program(wget)
check_program(xxd)
check_program(desktop-file-validate)
check_program(objcopy)
check_program(objdump)
check_program(readelf)
check_program(strip)
check_program(make)
# TODO: add checks for remaining commands
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <unistd.h>
#include <stdbool.h>
// include header of shared library, which contains more appimage_ functions
#include <appimage/appimage_shared.h>
/* Return the md5 hash constructed according to
* https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#THUMBSAVE
* This can be used to identify files that are related to a given AppImage at a given location */
char *appimage_get_md5(char const* path);
/* Check if a file is an AppImage. Returns the image type if it is, or -1 if it isn't */
int appimage_get_type(const char* path, bool verbose);
/*
* Finds the desktop file of a registered AppImage and returns the path
* Returns NULL if the desktop file can't be found, which should only occur when the AppImage hasn't been registered yet
*/
char* appimage_registered_desktop_file_path(const char* path, char* md5, bool verbose);
/*
* Check whether an AppImage has been registered in the system
*/
bool appimage_is_registered_in_system(const char* path);
/* Register a type 1 AppImage in the system */
bool appimage_type1_register_in_system(const char *path, bool verbose);
/* Register a type 2 AppImage in the system */
bool appimage_type2_register_in_system(const char *path, bool verbose);
/*
* Register an AppImage in the system
* Returns 0 on success, non-0 otherwise.
*/
int appimage_register_in_system(const char *path, bool verbose);
/* Unregister an AppImage in the system */
int appimage_unregister_in_system(const char *path, bool verbose);
/* Extract a given file from the appimage following the symlinks until a concrete file is found */
void appimage_extract_file_following_symlinks(const char* appimage_file_path, const char* file_path, const char* target_dir);
/* Read a given file from the AppImage into a freshly allocated buffer following symlinks
* Buffer must be free()d after usage
* */
bool appimage_read_file_into_buffer_following_symlinks(const char* appimage_file_path, const char* file_path, char** buffer, unsigned long* buf_size);
/* Create AppImage thumbnail according to
* https://specifications.freedesktop.org/thumbnail-spec/0.8.0/index.html
*/
void appimage_create_thumbnail(const char* appimage_file_path, bool verbose);
/* List files contained in the AppImage file.
* Returns: a newly allocated char** ended at NULL. If no files ware found also is returned a {NULL}
*
* You should ALWAYS take care of releasing this using `appimage_string_list_free`.
* */
char** appimage_list_files(const char* path);
/* Releases memory of a string list (a.k.a. list of pointers to char arrays allocated in heap memory). */
void appimage_string_list_free(char** list);
/*
* Checks whether a type 1 AppImage's desktop file has set Terminal=true.
*
* Returns >0 if set, 0 if not set, <0 on errors.
*/
int appimage_type1_is_terminal_app(const char* path);
/*
* Checks whether a type 2 AppImage's desktop file has set Terminal=true.
*
* Returns >0 if set, 0 if not set, <0 on errors.
*/
int appimage_type2_is_terminal_app(const char* path);
/*
* Checks whether an AppImage's desktop file has set Terminal=true.
*
* Returns >0 if set, 0 if not set, <0 on errors.
*/
int appimage_is_terminal_app(const char* path);
/*
* Checks whether a type 1 AppImage's desktop file has set X-AppImage-Version=false.
* Useful to check whether the author of an AppImage doesn't want it to be integrated.
*
* Returns >0 if set, 0 if not set, <0 on errors.
*/
int appimage_type1_shall_not_be_integrated(const char* path);
/*
* Checks whether a type 2 AppImage's desktop file has set X-AppImage-Version=false.
* Useful to check whether the author of an AppImage doesn't want it to be integrated.
*
* Returns >0 if set, 0 if not set, <0 on errors.
*/
int appimage_type2_shall_not_be_integrated(const char* path);
/*
* Checks whether an AppImage's desktop file has set X-AppImage-Version=false.
* Useful to check whether the author of an AppImage doesn't want it to be integrated.
*
* Returns >0 if set, 0 if not set, <0 on errors.
*/
int appimage_shall_not_be_integrated(const char* path);
/*
* Calculate the size of an ELF file on disk based on the information in its header
*
* Example:
*
* ls -l 126584
*
* Calculation using the values also reported by readelf -h:
* Start of section headers e_shoff 124728
* Size of section headers e_shentsize 64
* Number of section headers e_shnum 29
*
* e_shoff + ( e_shentsize * e_shnum ) = 126584
*/
ssize_t appimage_get_elf_size(const char* fname);
#ifdef __cplusplus
}
#endif
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdlib.h>
/*
* Return the offset, and the length of an ELF section with a given name in a given ELF file
*/
bool appimage_get_elf_section_offset_and_length(const char* fname, const char* section_name, unsigned long* offset, unsigned long* length);
int appimage_print_hex(char* fname, unsigned long offset, unsigned long length);
int appimage_print_binary(char* fname, unsigned long offset, unsigned long length);
/*
* Creates hexadecimal representation of a byte array. Allocates a new char array (string) with the correct size that
* needs to be free()d.
*/
char* appimage_hexlify(const char* bytes, size_t numBytes);
/*
* Calculate MD5 digest of AppImage file, skipping the signature and digest sections.
*
* The digest section must be skipped as the value calculated by this method is going to be embedded in it by default.
*
* The signature section must be skipped as the signature will not be available at the time this hash is calculated.
*
* The hash is _not_ compatible with tools like md5sum.
*
* You need to allocate a char array of at least 16 bytes (128 bit) and pass a reference to it as digest parameter.
* The function will set it to the raw digest, without any kind of termination. Please use appimage_hexlify() if you
* need a textual representation.
*
* Please beware that this calculation is only available for type 2 AppImages.
*/
bool appimage_type2_digest_md5(const char* fname, char* digest);
#ifdef __cplusplus
}
#endif
if(NOT TARGET gtest)
add_subdirectory(gtest EXCLUDE_FROM_ALL)
endif()
# required for pkg-config to create PkgConfig::<prefix> imported library targets
cmake_minimum_required(VERSION 3.6)
find_package(PkgConfig)
pkg_check_modules(glib glib-2.0>=2.40 IMPORTED_TARGET)
pkg_check_modules(gobject gobject-2.0>=2.40 IMPORTED_TARGET)
pkg_check_modules(gio gio-2.0>=2.40 IMPORTED_TARGET)
pkg_check_modules(zlib zlib IMPORTED_TARGET)
pkg_check_modules(cairo cairo IMPORTED_TARGET)
add_subdirectory(xdg-basedir)
add_subdirectory(libappimage_hashlib)
add_subdirectory(libappimage_shared)
add_subdirectory(libappimage)
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE libappimage)
# Create the AppImageConfig.cmake and AppImageConfigVersion files
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/libappimageConfig.cmake.in"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/libappimageConfig.cmake"
@ONLY
)
# ... for both
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/libappimageConfigVersion.cmake.in"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/libappimageConfigVersion.cmake"
@ONLY
)
# Install the AppImageConfig.cmake and AppImageConfigVersion.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libappimageConfig.cmake"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/libappimageConfigVersion.cmake"
DESTINATION "lib/cmake/libappimage"
COMPONENT libappimage-dev
)
# Install the export set for use with the install-tree
install(EXPORT libappimageTargets
DESTINATION "lib/cmake/libappimage"
COMPONENT libappimage-dev
)
cmake_minimum_required(VERSION 3.2)
set(libappimage_public_header ${PROJECT_SOURCE_DIR}/include/appimage/appimage.h)
# both libraries use the same set of source files
set(libappimage_sources
${libappimage_public_header}
libappimage.c
appimage_handler.h
appimage_handler.c
type1.c
type2.c
)
add_library(libappimage SHARED ${libappimage_sources} appimage_handler.h)
add_library(libappimage_static STATIC ${libappimage_sources})
# set common options
foreach(target libappimage libappimage_static)
# targets are called lib* already, so CMake shouldn't add another lib prefix to the actual files
set_target_properties(${target} PROPERTIES PREFIX "")
target_compile_definitions(${target}
PRIVATE -D_FILE_OFFSET_BITS=64
PRIVATE -DGIT_COMMIT="${GIT_COMMIT}"
PRIVATE -DENABLE_BINRELOC
)
target_include_directories(${target}
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
INTERFACE $<INSTALL_INTERFACE:include/>
)
target_link_libraries(${target}
PRIVATE libarchive
PRIVATE xdg-basedir
# not linking publicly to squashfuse as headers are not needed when using libappimage
# unit tests etc., which use squashfuse directly, must link to it explicitly
PRIVATE squashfuse
PRIVATE xz
PUBLIC libappimage_shared
PUBLIC pthread
PUBLIC libglib
PUBLIC libgobject
PUBLIC libgio
PUBLIC libzlib
PUBLIC libcairo
)
set_property(TARGET libappimage PROPERTY PUBLIC_HEADER ${libappimage_public_header})
endforeach()
# install libappimage
install(TARGETS libappimage
EXPORT libappimageTargets
LIBRARY DESTINATION lib COMPONENT libappimage
ARCHIVE DESTINATION lib/static COMPONENT libappimage
PUBLIC_HEADER DESTINATION include/appimage COMPONENT libappimage-dev
)
# Add all targets to the build-tree export set
export(
TARGETS libappimage libappimage_shared libappimage_hashlib
FILE "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/libappimageTargets.cmake"
)
// system includes
#include "stdio.h"
// library includes
#include <appimage/appimage.h>
// local includes
#include "appimage_handler.h"
#include "type1.h"
#include "type2.h"
/* Factory function for creating the right appimage handler for
* a given file. */
appimage_handler create_appimage_handler(const char *const path) {
int appimage_type = appimage_get_type(path, 0);
appimage_handler handler;
#ifdef STANDALONE
fprintf(stderr,"AppImage type: %d\n", appimage_type);
#endif
switch (appimage_type) {
case 1:
handler = appimage_type_1_create_handler();
break;
case 2:
handler = appimage_type_2_create_handler();
break;
default:
#ifdef STANDALONE
fprintf(stderr,"Appimage type %d not supported yet\n", appimage_type);
#endif
handler.traverse = dummy_traverse_func;
break;
}
handler.path = path;
handler.is_open = false;
return handler;
}
/*
* utility functions
*/
bool is_handler_valid(const appimage_handler *handler) {
if (handler == NULL) {
#ifdef STANDALONE
fprintf(stderr, "WARNING: Invalid handler found, you should take a look at this now!");
#endif
return false;
}
return true;
}
void mk_base_dir(const char *target)
{
gchar *dirname = g_path_get_dirname(target);
if(g_mkdir_with_parents(dirname, 0755)) {
#ifdef STANDALONE
fprintf(stderr, "Could not create directory: %s\n", dirname);
#endif
}
g_free(dirname);
}
/*
* Dummy fallback functions
*/
void dummy_traverse_func(appimage_handler *handler, traverse_cb command, void *data) {
(void) handler;
(void) command;
(void) data;
fprintf(stderr, "Called %s\n", __FUNCTION__);
}
char* dummy_get_file_name (appimage_handler *handler, void *data) {
fprintf(stderr, "Called %s\n", __FUNCTION__);
}
void dummy_extract_file(struct appimage_handler *handler, void *data, char *target) {
fprintf(stderr, "Called %s\n", __FUNCTION__);
}
\ No newline at end of file
#pragma once
// system includes
#include <glib.h>
#include <stdbool.h>
/* AppImage generic handler calback to be used in algorithms */
typedef void (*traverse_cb)(void* handler, void* entry_data, void* user_data);
/* AppImage generic handler to be used in algorithms */
struct appimage_handler {
const gchar* path;
char* (*get_file_name)(struct appimage_handler* handler, void* entry);
void (*extract_file)(struct appimage_handler* handler, void* entry, const char* target);
bool (*read_file_into_new_buffer)(struct appimage_handler* handler, void* entry, char** buffer, unsigned long* buffer_size);
void (*traverse)(struct appimage_handler* handler, traverse_cb command, void* user_data);
void* cache;
bool is_open;
// for debugging purposes
int type;