mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-09 18:07:00 -06:00
Update to 7-Zip Version 22.00
See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/9c2d9061ce/
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#ifndef _WIN32
|
||||
#include <fcntl.h> /* Definition of AT_* constants */
|
||||
#include "TimeUtils.h"
|
||||
// for major
|
||||
// #include <sys/sysmacros.h>
|
||||
#endif
|
||||
|
||||
#include "FileFind.h"
|
||||
@@ -62,24 +64,35 @@ bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize,
|
||||
|
||||
namespace NFind {
|
||||
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
#define MY_CLEAR_FILETIME(ft) ft.dwLowDateTime = ft.dwHighDateTime = 0;
|
||||
#else
|
||||
#define MY_CLEAR_FILETIME(ft) ft.tv_sec = 0; ft.tv_nsec = 0;
|
||||
#endif
|
||||
*/
|
||||
|
||||
void CFileInfoBase::ClearBase() throw()
|
||||
{
|
||||
Size = 0;
|
||||
MY_CLEAR_FILETIME(CTime);
|
||||
MY_CLEAR_FILETIME(ATime);
|
||||
MY_CLEAR_FILETIME(MTime);
|
||||
FiTime_Clear(CTime);
|
||||
FiTime_Clear(ATime);
|
||||
FiTime_Clear(MTime);
|
||||
|
||||
#ifdef _WIN32
|
||||
Attrib = 0;
|
||||
// ReparseTag = 0;
|
||||
IsAltStream = false;
|
||||
IsDevice = false;
|
||||
|
||||
#ifndef _WIN32
|
||||
#else
|
||||
dev = 0;
|
||||
ino = 0;
|
||||
nlink = 0;
|
||||
mode = 0;
|
||||
#endif
|
||||
nlink = 0;
|
||||
uid = 0;
|
||||
gid = 0;
|
||||
rdev = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CFileInfo::IsDots() const throw()
|
||||
@@ -439,6 +452,20 @@ also we support paths that are not supported by FindFirstFile:
|
||||
bool CFileInfo::Find(CFSTR path, bool followLink)
|
||||
{
|
||||
#ifdef SUPPORT_DEVICE_FILE
|
||||
|
||||
if (IS_PATH_SEPAR(path[0]) &&
|
||||
IS_PATH_SEPAR(path[1]) &&
|
||||
path[2] == '.' &&
|
||||
path[3] == 0)
|
||||
{
|
||||
// 22.00 : it's virtual directory for devices
|
||||
// IsDevice = true;
|
||||
ClearBase();
|
||||
Name = path + 2;
|
||||
Attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsDevicePath(path))
|
||||
{
|
||||
ClearBase();
|
||||
@@ -469,7 +496,7 @@ bool CFileInfo::Find(CFSTR path, bool followLink)
|
||||
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
|
||||
int colonPos = FindAltStreamColon(path);
|
||||
const int colonPos = FindAltStreamColon(path);
|
||||
if (colonPos >= 0 && path[(unsigned)colonPos + 1] != 0)
|
||||
{
|
||||
UString streamName = fs2us(path + (unsigned)colonPos);
|
||||
@@ -635,7 +662,7 @@ bool CFileInfo::Find(CFSTR path, bool followLink)
|
||||
return Fill_From_ByHandleFileInfo(path);
|
||||
}
|
||||
|
||||
bool CFileInfo::Fill_From_ByHandleFileInfo(CFSTR path)
|
||||
bool CFileInfoBase::Fill_From_ByHandleFileInfo(CFSTR path)
|
||||
{
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
if (!NIO::CFileBase::GetFileInformation(path, &info))
|
||||
@@ -950,13 +977,6 @@ static const char *Get_Name_from_Path(CFSTR path) throw()
|
||||
}
|
||||
|
||||
|
||||
void timespec_To_FILETIME(const MY_ST_TIMESPEC &ts, FILETIME &ft)
|
||||
{
|
||||
UInt64 v = NTime::UnixTime64ToFileTime64(ts.tv_sec) + ((UInt64)ts.tv_nsec / 100);
|
||||
ft.dwLowDateTime = (DWORD)v;
|
||||
ft.dwHighDateTime = (DWORD)(v >> 32);
|
||||
}
|
||||
|
||||
UInt32 Get_WinAttribPosix_From_PosixMode(UInt32 mode)
|
||||
{
|
||||
UInt32 attrib = S_ISDIR(mode) ?
|
||||
@@ -984,7 +1004,7 @@ UInt32 Get_WinAttrib_From_stat(const struct stat &st)
|
||||
|
||||
void CFileInfo::SetFrom_stat(const struct stat &st)
|
||||
{
|
||||
IsDevice = false;
|
||||
// IsDevice = false;
|
||||
|
||||
if (S_ISDIR(st.st_mode))
|
||||
{
|
||||
@@ -995,7 +1015,7 @@ void CFileInfo::SetFrom_stat(const struct stat &st)
|
||||
Size = (UInt64)st.st_size; // for a symbolic link, size = size of filename
|
||||
}
|
||||
|
||||
Attrib = Get_WinAttribPosix_From_PosixMode(st.st_mode);
|
||||
// Attrib = Get_WinAttribPosix_From_PosixMode(st.st_mode);
|
||||
|
||||
// NTime::UnixTimeToFileTime(st.st_ctime, CTime);
|
||||
// NTime::UnixTimeToFileTime(st.st_mtime, MTime);
|
||||
@@ -1010,27 +1030,89 @@ void CFileInfo::SetFrom_stat(const struct stat &st)
|
||||
*/
|
||||
// timespec_To_FILETIME(st.st_birthtimespec, CTime);
|
||||
// #else
|
||||
timespec_To_FILETIME(st.st_ctimespec, CTime);
|
||||
// timespec_To_FILETIME(st.st_ctimespec, CTime);
|
||||
// #endif
|
||||
timespec_To_FILETIME(st.st_mtimespec, MTime);
|
||||
timespec_To_FILETIME(st.st_atimespec, ATime);
|
||||
// timespec_To_FILETIME(st.st_mtimespec, MTime);
|
||||
// timespec_To_FILETIME(st.st_atimespec, ATime);
|
||||
CTime = st.st_ctimespec;
|
||||
MTime = st.st_mtimespec;
|
||||
ATime = st.st_atimespec;
|
||||
|
||||
#else
|
||||
timespec_To_FILETIME(st.st_ctim, CTime);
|
||||
timespec_To_FILETIME(st.st_mtim, MTime);
|
||||
timespec_To_FILETIME(st.st_atim, ATime);
|
||||
// timespec_To_FILETIME(st.st_ctim, CTime, &CTime_ns100);
|
||||
// timespec_To_FILETIME(st.st_mtim, MTime, &MTime_ns100);
|
||||
// timespec_To_FILETIME(st.st_atim, ATime, &ATime_ns100);
|
||||
CTime = st.st_ctim;
|
||||
MTime = st.st_mtim;
|
||||
ATime = st.st_atim;
|
||||
|
||||
#endif
|
||||
|
||||
dev = st.st_dev;
|
||||
ino = st.st_ino;
|
||||
nlink = st.st_nlink;
|
||||
mode = st.st_mode;
|
||||
nlink = st.st_nlink;
|
||||
uid = st.st_uid;
|
||||
gid = st.st_gid;
|
||||
rdev = st.st_rdev;
|
||||
|
||||
/*
|
||||
printf("\n sizeof timespec = %d", (int)sizeof(timespec));
|
||||
printf("\n sizeof st_rdev = %d", (int)sizeof(rdev));
|
||||
printf("\n sizeof st_ino = %d", (int)sizeof(ino));
|
||||
printf("\n sizeof mode_t = %d", (int)sizeof(mode_t));
|
||||
printf("\n sizeof nlink_t = %d", (int)sizeof(nlink_t));
|
||||
printf("\n sizeof uid_t = %d", (int)sizeof(uid_t));
|
||||
printf("\n");
|
||||
*/
|
||||
/*
|
||||
printf("\n st_rdev = %llx", (long long)rdev);
|
||||
printf("\n st_dev = %llx", (long long)dev);
|
||||
printf("\n dev : major = %5x minor = %5x", (unsigned)major(dev), (unsigned)minor(dev));
|
||||
printf("\n st_ino = %lld", (long long)(ino));
|
||||
printf("\n rdev : major = %5x minor = %5x", (unsigned)major(rdev), (unsigned)minor(rdev));
|
||||
printf("\n size = %lld \n", (long long)(Size));
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
int Uid_To_Uname(uid_t uid, AString &name)
|
||||
{
|
||||
name.Empty();
|
||||
struct passwd *passwd;
|
||||
|
||||
if (uid != 0 && uid == cached_no_such_uid)
|
||||
{
|
||||
*uname = xstrdup ("");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cached_uname || uid != cached_uid)
|
||||
{
|
||||
passwd = getpwuid (uid);
|
||||
if (passwd)
|
||||
{
|
||||
cached_uid = uid;
|
||||
assign_string (&cached_uname, passwd->pw_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
cached_no_such_uid = uid;
|
||||
*uname = xstrdup ("");
|
||||
return;
|
||||
}
|
||||
}
|
||||
*uname = xstrdup (cached_uname);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CFileInfo::Find_DontFill_Name(CFSTR path, bool followLink)
|
||||
{
|
||||
struct stat st;
|
||||
if (MY__lstat(path, &st, followLink) != 0)
|
||||
return false;
|
||||
// printf("\nFind_DontFill_Name : name=%s\n", path);
|
||||
SetFrom_stat(st);
|
||||
return true;
|
||||
}
|
||||
@@ -1232,6 +1314,7 @@ bool CEnumerator::Fill_FileInfo(const CDirEntry &de, CFileInfo &fileInfo, bool f
|
||||
|
||||
if (res != 0)
|
||||
return false;
|
||||
// printf("\nname=%s\n", de.Name.Ptr());
|
||||
fileInfo.SetFrom_stat(st);
|
||||
fileInfo.Name = de.Name;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user