View Issue Details

IDProjectCategoryView StatusLast Update
0006508The Dark ModCodingpublic04.05.2025 22:32
Reporteres20490446e Assigned Tostgatilov  
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionreopened 
Fixed in VersionTDM 2.14 
Summary0006508: tdm_installer: fails to build: missing include: cstdint
DescriptionWith current build tools you have to explicitly import some standard C symbols, or the build fails.
Tagsbuild
Attached Files
error.txt (3,424 bytes)   
compile: make:
In file included from /home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.cpp:1:
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.h:68:14: error: ‘uintmax_t’ in namespace ‘std’ does not name a type
   68 |         std::uintmax_t capacity;
      |              ^~~~~~~~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.h:10:1: note: ‘std::uintmax_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    9 | #include <system_error>
  +++ |+#include <cstdint>
   10 |
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.h:69:14: error: ‘uintmax_t’ in namespace ‘std’ does not name a type
   69 |         std::uintmax_t free;
      |              ^~~~~~~~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.h:69:9: note: ‘std::uintmax_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
   69 |         std::uintmax_t free;
      |         ^~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.h:70:14: error: ‘uintmax_t’ in namespace ‘std’ does not name a type
   70 |         std::uintmax_t available;
      |              ^~~~~~~~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.h:70:9: note: ‘std::uintmax_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
   70 |         std::uintmax_t available;
      |         ^~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.cpp: In function ‘stdext::space_info stdext::space(const path&)’:
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.cpp:205:13: error: ‘struct stdext::space_info’ has no member named ‘capacity’
  205 |         res.capacity = stdres.capacity;
      |             ^~~~~~~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.cpp:206:13: error: ‘struct stdext::space_info’ has no member named ‘free’
  206 |         res.free = stdres.free;
      |             ^~~~
/home/es20490446e/Documents/Projects/Ikigai/darkmod/darkmod-linux/_BUILD/1-workspace.../6-buildInstaller.../tdm_installer/zipsync/StdFilesystem.cpp:207:13: error: ‘struct stdext::space_info’ has no member named ‘available’
  207 |         res.available = stdres.available;
      |             ^~~~~~~~~
make[2]: *** [zipsync/CMakeFiles/libzipsyncextra.dir/build.make:76: zipsync/CMakeFiles/libzipsyncextra.dir/StdFilesystem.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:155: zipsync/CMakeFiles/libzipsyncextra.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
✗ 1
error.txt (3,424 bytes)   
fix.zip (1,554 bytes)

Activities

es20490446e

es20490446e

01.09.2024 00:31

reporter   ~0016821

Please add this fix.
es20490446e

es20490446e

25.03.2025 03:08

reporter   ~0016996

Please include this fix. It's just one line.
stgatilov

stgatilov

27.04.2025 08:27

administrator   ~0017010

Hopefully fixed in svn rev 10995...
es20490446e

es20490446e

27.04.2025 12:35

reporter   ~0017014

Let me test...
es20490446e

es20490446e

29.04.2025 17:56

reporter   ~0017015

@stgatilov

The bug is still there.

Correct:
https://gitlab.com/es20490446e/darkmod-linux/-/raw/master/patches/buildDevelWorkspace/darkmod_src/tdm_installer/zipsync/StdFilesystem.h?ref_type=heads

Incorrect:
https://svn.thedarkmod.com/publicsvn/darkmod_src/trunk/tdm_installer/zipsync/StdFilesystem.h
es20490446e

es20490446e

29.04.2025 17:58

reporter   ~0017016

Still there.
stgatilov

stgatilov

01.05.2025 16:17

administrator   ~0017018

And what is the new error BTW?
es20490446e

es20490446e

01.05.2025 16:27

reporter   ~0017019

The compiler complains that you have to explicitly "#include <cstdint>".
stgatilov

stgatilov

04.05.2025 09:08

administrator   ~0017021

Okay, added the include in svn rev 10999.
es20490446e

es20490446e

04.05.2025 21:28

reporter   ~0017022

Testing...
es20490446e

es20490446e

04.05.2025 22:32

reporter   ~0017023

At:
tdm_installer/zipsync

You also have to add:
#include <cstdint>

To:
- Downloader.h
- Utils.h
- ZipUtils.h
Downloader.h (5,600 bytes)   
#pragma once

#include <limits.h>
#include <cstdint>
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>


typedef void CURL;

namespace ZipSync {

/**
 * A chunk of data which we want to download
 */
struct DownloadSource {
    //URL to download file from
    std::string url;
    //the range of bytes to be downloaded
    //byterange[1] == UINT_MAX means: download whole file of unknown size
    uint32_t byterange[2];

    DownloadSource();
    DownloadSource(const std::string &url); //download whole file
    DownloadSource(const std::string &url, uint32_t from, uint32_t to); //download range of file
};

//called when download is complete
typedef std::function<void(const void*, uint32_t)> DownloadFinishedCallback;
//called during download to report progress: returning nonzero value interrupts download
typedef std::function<int(double, const char*)> GlobalProgressCallback;


/**
 * Smart downloader over HTTP protocol.
 * Utilizes byteranges and multipart byteranges requests to download many chunks quickly.
 * On a problematic network, can split download into many small pieces to cope with occasional timeouts.
 */
class Downloader {
    bool _silentErrors = false;
    std::unique_ptr<std::string> _useragent;
    bool _blockMultipart = false;
    GlobalProgressCallback _progressCallback;

    //user-specified chunk of data to be downloaded
    struct Download {
        DownloadSource src;
        DownloadFinishedCallback finishedCallback;
        std::vector<uint8_t> resultData;    //temporary storage (used in case download is split)
        int64_t progressSize = 0;           //estimated size in bytes (for progress indicator)
    };
    std::vector<Download> _downloads;

    //state of one remote file processed
    //usually contains several user-specified "Download"-s
    struct UrlState {
        std::vector<int> downloadsIds;      //indices in _downloads (sorted by starting offset)
        int doneCnt = 0;                    //how many FULL downloads done
        uint32_t doneBytesNext = 0;         //how many bytes done in the current download
        int speedProfile = 0;               //index in SPEED_PROFILES
    };
    std::map<std::string, UrlState> _urlStates;

    //designates user-specified "Download" or a piece of it
    //every HTTP request contains one or several SubTasks
    struct SubTask {
        int downloadIdx;                    //index in _downloads
        uint32_t byterange[2];              //can be part of download's byterange
    };
    //state of the HTTP request currently active
    struct CurlResponse {
        std::string url;

        std::vector<uint8_t> data;          //downloaded file data is appended to here
        uint32_t totalSize = UINT_MAX;      //size of file as reported by HTTP header (used for whole-file downloads)
        uint32_t onerange[2] = {UINT_MAX, UINT_MAX};    //byterange actually provided by HTTP server (may differ from what we asked for)
        std::string boundary;               //boundary between responses in multipart response

        double progressRatio = 0.0;         //which portion of this CURL request is done
        int64_t bytesDownloaded = 0;        //how many bytes actually downloaded (as reported by CURL)
        double progressWeight = 0.0;        //this request size / total size of all downloads
    };
    std::unique_ptr<CurlResponse> _currResponse;

    double _totalProgress = 0.0;            //which portion of DownloadAll is complete (without current request)
    int64_t _totalBytesDownloaded = 0;      //how many bytes downloaded in total (without current request)

    std::unique_ptr<CURL, void (*)(CURL*)> _curlHandle; //CURL handle reused between request in order to exploit connection pool
    int _curlRequestIdx = 0;                //sequental number of HTTP request (used for logging curl commands)

public:
    ~Downloader();
    Downloader();

    //schedule download of specified chunk of data
    //the obtained data will be passed to the specified callback when it is available
    void EnqueueDownload(const DownloadSource &source, const DownloadFinishedCallback &finishedCallback);

    //progress callback is useful for two things:
    // * showing progress indicator to user (use passed argument)
    // * allowing user to interrupt download (return nonzero value)
    void SetProgressCallback(const GlobalProgressCallback &progressCallback);
    // * silent == false: throw exception on any error up to the caller, stopping the whole run
    // * silent == true: just don't call callback function for failed requests (grouped by url), no stopping, no exception
    void SetErrorMode(bool silent);
    //set user-agent to be put into HTTP request
    void SetUserAgent(const char *useragent);
    //blocked = true: only use ordinary byterange requests, never use multipart ones
    void SetMultipartBlocked(bool blocked);

    //when everything is set up, call this method to actually perform all downloads
    //it blocks until the job is done (progress callback is the only way to interrupt it)
    void DownloadAll();

    //returns total number of bytes downloaded by this object
    //(as reported by CURL)
    int64_t TotalBytesDownloaded() const { return _totalBytesDownloaded; }

private:
    void DownloadAllForUrl(const std::string &url);
    bool DownloadOneRequest(const std::string &url, const std::vector<SubTask> &subtasks, int lowSpeedTime, int connectTimeout);
    void BreakMultipartResponse(const CurlResponse &response, std::vector<CurlResponse> &parts);
    int UpdateProgress();
};

}
Downloader.h (5,600 bytes)   
Utils.h (1,027 bytes)   
#pragma once

#include <cstdint>
#include <memory>
#include <string>
#include <vector>


namespace ZipSync {

static const int SIZE_PATH = 4<<10;
static const int SIZE_FILEBUFFER = 64<<10;
static const int SIZE_LINEBUFFER = 16<<10;


template<class T> void AppendVector(std::vector<T> &dst, const std::vector<T> &src) {
    dst.insert(dst.end(), src.begin(), src.end());
}


typedef std::unique_ptr<FILE, int (*)(FILE*)> StdioFileUniquePtr;
/**
 * RAII wrapper around FILE* from stdio.h.
 * Automatically closes file on destruction.
 */
class StdioFileHolder : public StdioFileUniquePtr {
public:
    StdioFileHolder(FILE *f);
    StdioFileHolder(const char *path, const char *mode);    //checks that file is opened successfully
    ~StdioFileHolder();
    StdioFileHolder(StdioFileHolder&&) = default;
    StdioFileHolder& operator=(StdioFileHolder&&) = default;
    operator FILE*() const { return get(); }
};

std::vector<uint8_t> ReadWholeFile(const std::string &filename);
int GetFileSize(const std::string &filename);

}
Utils.h (1,027 bytes)   
ZipUtils.h (2,802 bytes)   
#pragma once

#include "Logging.h"
#include <minizip/unzip.h>
#include <minizip/zip.h>
#include <cstdint>
#include <memory>
#include <vector>


namespace ZipSync {

typedef std::unique_ptr<std::remove_pointer<unzFile>::type, int (*)(unzFile)> UnzFileUniquePtr;
/**
 * RAII wrapper around unzFile from minizip.h.
 * Automatically closes file on destruction.
 */
class UnzFileHolder : public UnzFileUniquePtr {
public:
    UnzFileHolder(unzFile zf);
    UnzFileHolder(const char *path);
    ~UnzFileHolder();
    operator unzFile() const { return get(); }
};

typedef std::unique_ptr<std::remove_pointer<zipFile>::type, int (*)(zipFile)> ZipFileUniquePtr;
/**
 * RAII wrapper around zipFile from minizip.h.
 * Automatically closes file on destruction.
 */
class ZipFileHolder : public ZipFileUniquePtr {
public:
    ZipFileHolder(zipFile zf);
    ZipFileHolder(const char *path);
    ~ZipFileHolder();
    operator zipFile() const { return get(); }
};


/**
 * Performs whatever call you wrap into it and checks its return code.
 * If the return code is nonzero, then exception is thrown.
 */
#define SAFE_CALL(...) \
    do { \
        int mz_errcode = __VA_ARGS__; \
        if (mz_errcode != 0) g_logger->errorf(lcMinizipError, "Minizip error %d", mz_errcode); \
    } while (0)


//note: file must be NOT opened
void unzGetCurrentFilePosition(unzFile zf, uint32_t *localHeaderStart, uint32_t *fileDataStart, uint32_t *fileDataEnd);

class UnzFileIndexed {
    struct Entry {
        uint32_t byterangeStart;
        unz_file_pos unzPos;
        bool operator< (const Entry &b) const;
    };
    UnzFileUniquePtr _zfHandle;
    std::vector<Entry> _sortedEntries;
public:
    ~UnzFileIndexed();
    UnzFileIndexed();
    UnzFileIndexed(UnzFileIndexed &&) = default;
    operator unzFile() const { return _zfHandle.get(); }
    void Clear();
    void Open(const char *path);
    void LocateByByterange(uint32_t start, uint32_t end);
};

/*
//like unzLocateFile, but also checks exact match by byterange (which includes local file header)
bool unzLocateFileAtBytes(unzFile zf, const char *filename, uint32_t from, uint32_t to);
*/

void minizipCopyFile(unzFile zf, zipFile zfOut, const char *filename, int method, int flags, uint16_t internalAttribs, uint32_t externalAttribs, uint32_t dosDate, bool copyRaw, uint32_t crc, uint32_t contentsSize);

struct FileAttribInfo {
    uint32_t offset;
    uint32_t externalAttribs;
    uint16_t internalAttribs;
};
//given a tightly packed zip file without central directory, rebuilds it and appends it to the end of file
void minizipAddCentralDirectory(const char *filename, std::vector<FileAttribInfo> attribs = {});

//repack given zip file so that it gets accepted by ZipSync
void minizipNormalize(const char *srcFilename, const char *dstFilename = NULL);

}
ZipUtils.h (2,802 bytes)   

Issue History

Date Modified Username Field Change
26.03.2024 18:53 es20490446e New Issue
26.03.2024 18:53 es20490446e File Added: error.txt
26.03.2024 18:53 es20490446e File Added: fix.zip
09.04.2024 18:43 Fiver Tag Attached: build
01.09.2024 00:31 es20490446e Note Added: 0016821
25.03.2025 03:08 es20490446e Note Added: 0016996
27.04.2025 08:27 stgatilov Note Added: 0017010
27.04.2025 08:27 stgatilov Assigned To => stgatilov
27.04.2025 08:27 stgatilov Status new => resolved
27.04.2025 08:27 stgatilov Resolution open => fixed
27.04.2025 08:27 stgatilov Fixed in Version => TDM 2.14
27.04.2025 12:35 es20490446e Note Added: 0017014
29.04.2025 17:56 es20490446e Note Added: 0017015
29.04.2025 17:58 es20490446e Status resolved => feedback
29.04.2025 17:58 es20490446e Resolution fixed => reopened
29.04.2025 17:58 es20490446e Note Added: 0017016
29.04.2025 17:59 es20490446e Status feedback => new
29.04.2025 17:59 es20490446e Resolution reopened => open
01.05.2025 16:17 stgatilov Note Added: 0017018
01.05.2025 16:27 es20490446e Note Added: 0017019
04.05.2025 09:08 stgatilov Note Added: 0017021
04.05.2025 09:08 stgatilov Status new => resolved
04.05.2025 09:08 stgatilov Resolution open => fixed
04.05.2025 21:28 es20490446e Note Added: 0017022
04.05.2025 22:32 es20490446e Note Added: 0017023
04.05.2025 22:32 es20490446e File Added: Downloader.h
04.05.2025 22:32 es20490446e File Added: Utils.h
04.05.2025 22:32 es20490446e File Added: ZipUtils.h
04.05.2025 22:32 es20490446e Status resolved => new
04.05.2025 22:32 es20490446e Resolution fixed => reopened