Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Ist eine Datei komprimiert? (https://www.delphipraxis.net/80665-ist-eine-datei-komprimiert.html)

alcaeus 13. Nov 2006 13:31


Ist eine Datei komprimiert?
 
Hallo,

wie kann ich rausfinden, ob eine bestimmte Datei komprimiert (mit der Dateikomprimierung unter XP) auf der Festplatte liegt oder nicht? Ich braeuchte das um rauszufinden ob ich die Anzahl belegter Cluster anhand der echten Dateigroesse oder anhand der komprimierten Dateigroesse berechnen muss; dies kann ja fuer jede Datei anders sein.

Danke schonmal,
alcaeus

Luckie 13. Nov 2006 13:37

Re: Ist eine Datei komprimiert?
 
Guck mal hier: MSDN-Library durchsuchenDeviceIOControl und dem Flag: FSCTL_GET_COMPRESSION
Zitat:

Compression State
Each file and directory on a volume that supports compression for individual files and directories has a compression state.


Whereas the compression attribute of a file or directory indicates simply whether the file or directory is compressed or not compressed, the compression state also specifies the format of any compressed data.

Use the FSCTL_GET_COMPRESSION control code to determine the compression state of a file or directory.

Compression state is encoded as a 16-bit value. A compression state value of COMPRESSION_FORMAT_NONE indicates that a file is not compressed. A value of COMPRESSION_FORMAT_DEFAULT indicates that a file is compressed, using the default compression format. Any other value indicates that a file is compressed, using the compression format specified by the compression state value.

Use the FSCTL_SET_COMPRESSION control code to set the compression state of a file or directory. This operation also sets the compression attribute of the file or directory.

Setting the compression state of a file to a nonzero value compresses the file, using the compression format encoded by the compression state value. Setting a file's compression state to zero decompresses the file. These are synchronous operations. The file is compressed or decompressed immediately when you set its compression state.

Setting a directory's compression state does not cause any immediate compression or decompression. Instead, setting a directory's compression state sets a default compression state that will be given to all newly created files and subdirectories.

alcaeus 13. Nov 2006 13:40

Re: Ist eine Datei komprimiert?
 
Danke!

Greetz
alcaeus

himitsu 17. Nov 2006 12:17

Re: Ist eine Datei komprimiert?
 
Zum Auslesen/Prüfen geht's hiermit wohl einfacher:
MSDN-Library durchsuchenGetFileAttributes + FILE_ATTRIBUTE_COMPRESSED :zwinker:
Nur zum Setzen/Ändern muß MSDN-Library durchsuchenFSCTL_SET_COMPRESSION verwendet werden.


Und zur Größe ... MSDN-Library durchsuchenGetCompressedFileSize und MSDN-Library durchsuchenGetFileSize ^^
(GetCompressedFileSize sollte auch beu unkomprimierten Dateien funktionieren)



:!: Ach ja, wenn schon, dann sollte an auf ungleich COMPRESSION_FORMAT_NONE prüfen ... derzeit gibt's zwar nur einen Kompressionsmudus, aber das kann sich ja noch ändern.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:51 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz