year = (unsigned)(1601 + v / PERIOD_400 * 400);
v %= PERIOD_400;
t = v / PERIOD_100; if (t == 4) t = 3; year += t * 100; v -= t * PERIOD_100;
t = v / PERIOD_4; if (t == 25) t = 24; year += t * 4; v -= t * PERIOD_4;
t = v / 365; if (t == 4) t = 3; year += t; v -= t * 365;
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
ms[1] = 29;
for (mon = 0;; mon++)
{ unsigned d = ms[mon];
if (v < d) break;
v -= d;
}
s = UIntToStr(s, year, 4); *s++ = '-';
UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3;
UIntToStr_2(s, (unsigned)v + 1); s[2] = ' '; s += 3;
UIntToStr_2(s, hour); s[2] = ':'; s += 3;
UIntToStr_2(s, min); s[2] = ':'; s += 3;
UIntToStr_2(s, sec); s[2] = 0;
}
if (numargs == 1)
{
Print( "Usage: 7zDec <command> <archive_name>\n\n" "<Commands>\n" " e: Extract files from archive (without using directory names)\n" " l: List contents of archive\n" " t: Test integrity of archive\n" " x: eXtract files with full paths\n"); return0;
}
if (numargs < 3)
{
PrintError("incorrect command"); return1;
}
#ifdef UNDER_CE
if (InFile_OpenW(&archiveStream.file, L"\test.7z")) #else
if (InFile_Open(&archiveStream.file, args[2])) #endif
{
PrintError("can not open input file"); return1;
}
if (res == SZ_OK)
{
res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp);
}
if (res == SZ_OK)
{
char *command = args[1];
int listCommand = 0, testCommand = 0, fullPaths = 0;
if (strcmp(command, "l") == 0) listCommand = 1; else if (strcmp(command, "t") == 0) testCommand = 1; else if (strcmp(command, "e") == 0) { } else if (strcmp(command, "x") == 0) { fullPaths = 1; } else
{
PrintError("incorrect command");
res = SZ_ERROR_FAIL;
}
if (res == SZ_OK)
{
UInt32 i;
/* ifyouneedcache,usethese3variables. ifyouuseexternalfunction,youcanmakethesevariableasstatic.
*/
UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
for (i = 0; i < db.NumFiles; i++)
{
size_t offset = 0;
size_t outSizeProcessed = 0; // const CSzFileItem *f = db.Files + i;
size_t len; unsigned isDir = SzArEx_IsDir(&db, i);
if (listCommand == 0 && isDir && !fullPaths) continue;
len = SzArEx_GetFileNameUtf16(&db, i, NULL); // len = SzArEx_GetFullNameLen(&db, i);
if (len > tempSize)
{
SzFree(NULL, temp);
tempSize = len;
temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));
if (!temp)
{
res = SZ_ERROR_MEM; break;
}
}
SzArEx_GetFileNameUtf16(&db, i, temp); /* if(SzArEx_GetFullNameUtf16_Back(&db,i,temp+len)!=temp) { res=SZ_ERROR_FAIL; break; }
*/
if (listCommand)
{
char attr[8], s[32], t[32];
UInt64 fileSize;
for (j = 0; name[j] != 0; j++)
if (name[j] == '/')
{
if (fullPaths)
{
name[j] = 0;
MyCreateDir(name);
name[j] = CHAR_PATH_SEPARATOR;
} else
destPath = name + j + 1;
}
if (isDir)
{
MyCreateDir(destPath);
PrintLF(); continue;
} else if (OutFile_OpenUtf16(&outFile, destPath))
{
PrintError("can not open output file");
res = SZ_ERROR_FAIL; break;
}
processedSize = outSizeProcessed;
if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed)
{
PrintError("can not write output file");
res = SZ_ERROR_FAIL; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.