Skip to content

Commit

Permalink
improved compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cielavenir committed Apr 10, 2022
1 parent bd82e8a commit 3371b8e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion C/7zip_gcc_c.mak
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ MY_MKDIR=mkdir -p

# LOCAL_LIBS=-lpthread
# LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
LIB2 = -lpthread -ldl
LIB2 = -pthread -ldl

DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS)

Expand Down
5 changes: 3 additions & 2 deletions CPP/7zip/7zip_gcc.mak
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CFLAGS_BASE_LIST = -c
# CFLAGS_BASE_LIST = -S
CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
-DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
$(CFLAGS_ADDITIONAL)


# -D_7ZIP_AFFINITY_DISABLE
Expand Down Expand Up @@ -119,7 +120,7 @@ MY_MKDIR=mkdir -p

# LOCAL_LIBS=-lpthread
# LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
LIB2 = -lpthread -ldl
LIB2 = -pthread -ldl



Expand All @@ -129,7 +130,7 @@ endif



CFLAGS = $(MY_ARCH_2) $(LOCAL_FLAGS) $(CFLAGS_BASE2) $(CFLAGS_BASE) $(CC_SHARED) -o $@
CFLAGS = $(MY_ARCH_2) $(LOCAL_FLAGS) $(CFLAGS_BASE2) $(CFLAGS_BASE) -std=c99 $(CC_SHARED) -o $@

ifdef IS_MINGW
ifdef IS_X64
Expand Down
4 changes: 4 additions & 0 deletions CPP/7zip/7zip_gcc_additional.mak
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ ifneq ($(findstring mingw32,$(CC)),)
DCMAKE_SYSTEM_NAME := -DCMAKE_SYSTEM_NAME=Windows
endif

ifneq ($(findstring linux,$(CC)),)
DCMAKE_SYSTEM_NAME := -DCMAKE_SYSTEM_NAME=Linux
endif

# Build MT API
$O/lz4-mt_common.o: ../../../../Codecs/zstdmt/lib/lz4-mt_common.c
$(CC) $(CFLAGS) $< -I ../../../../Codecs/lz4/lib
Expand Down
13 changes: 13 additions & 0 deletions CPP/7zip/Common/FileStreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <unistd.h>
#include <errno.h>
#include "../../Windows/FileFind.h"
#include "../../Windows/TimeUtils.h"
#endif

#ifdef SUPPORT_DEVICE_FILE
Expand Down Expand Up @@ -347,6 +348,11 @@ STDMETHODIMP CInFileStream::GetProps(UInt64 *size, FILETIME *cTime, FILETIME *aT
return GetLastError_HRESULT();

if (size) *size = (UInt64)st.st_size;
#ifdef NOTIMESPEC
if (cTime) NWindows::NTime::UnixTimeToFileTime(st.st_ctime, *cTime);
if (aTime) NWindows::NTime::UnixTimeToFileTime(st.st_atime, *aTime);
if (mTime) NWindows::NTime::UnixTimeToFileTime(st.st_mtime, *mTime);
#else
#ifdef __APPLE__
if (cTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_ctimespec, *cTime);
if (aTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atimespec, *aTime);
Expand All @@ -356,6 +362,7 @@ STDMETHODIMP CInFileStream::GetProps(UInt64 *size, FILETIME *cTime, FILETIME *aT
if (aTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atim, *aTime);
if (mTime) NWindows::NFile::NFind::timespec_To_FILETIME(st.st_mtim, *mTime);
#endif
#endif
if (attrib) *attrib = NWindows::NFile::NFind::Get_WinAttribPosix_From_PosixMode(st.st_mode);

return S_OK;
Expand All @@ -381,6 +388,11 @@ STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
props->NumLinks = (UInt32)st.st_nlink; // we reduce to UInt32 from (nlink_t) that is (unsigned long)
props->Attrib = NWindows::NFile::NFind::Get_WinAttribPosix_From_PosixMode(st.st_mode);

#ifdef NOTIMESPEC
NWindows::NTime::UnixTimeToFileTime(st.st_ctime, props->CTime);
NWindows::NTime::UnixTimeToFileTime(st.st_atime, props->ATime);
NWindows::NTime::UnixTimeToFileTime(st.st_mtime,props->MTime);
#else
#ifdef __APPLE__
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_ctimespec, props->CTime);
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atimespec, props->ATime);
Expand All @@ -390,6 +402,7 @@ STDMETHODIMP CInFileStream::GetProps2(CStreamFileProps *props)
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_atim, props->ATime);
NWindows::NFile::NFind::timespec_To_FILETIME(st.st_mtim, props->MTime);
#endif
#endif

/*
printf("\nGetProps2() NumLinks=%d = st_dev=%d st_ino = %d\n"
Expand Down
1 change: 1 addition & 0 deletions CPP/Windows/FileDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ bool SetDirTime(CFSTR path, const FILETIME *cTime, const FILETIME *aTime, const
{
// need testing
#if 1
//def NOTIMESPEC
struct utimbuf buf;
struct stat st;
UNUSED_VAR(cTime)
Expand Down
9 changes: 6 additions & 3 deletions CPP/Windows/FileFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,11 @@ void CFileInfo::SetFrom_stat(const struct stat &st)

Attrib = Get_WinAttribPosix_From_PosixMode(st.st_mode);

// NTime::UnixTimeToFileTime(st.st_ctime, CTime);
// NTime::UnixTimeToFileTime(st.st_mtime, MTime);
// NTime::UnixTimeToFileTime(st.st_atime, ATime);
#ifdef NOTIMESPEC
NTime::UnixTimeToFileTime(st.st_ctime, CTime);
NTime::UnixTimeToFileTime(st.st_mtime, MTime);
NTime::UnixTimeToFileTime(st.st_atime, ATime);
#else
#ifdef __APPLE__
// #ifdef _DARWIN_FEATURE_64_BIT_INODE
/*
Expand All @@ -1019,6 +1021,7 @@ void CFileInfo::SetFrom_stat(const struct stat &st)
timespec_To_FILETIME(st.st_mtim, MTime);
timespec_To_FILETIME(st.st_atim, ATime);
#endif
#endif

dev = st.st_dev;
ino = st.st_ino;
Expand Down

0 comments on commit 3371b8e

Please sign in to comment.