AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Is volume compressed?

Ein Thema von WojTec · begonnen am 5. Feb 2014 · letzter Beitrag vom 6. Feb 2014
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Is volume compressed?

  Alt 5. Feb 2014, 16:40
Delphi-Version: 2010
How to receive from GetVolumeInformation.lpFileSystemFlags if volume is compressed or not?

I have FileSysFlags and FILE_VOLUME_IS_COMPRESSED <> 0 but not working. F1, please.
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.542 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Is volume compressed?

  Alt 5. Feb 2014, 16:48
Do you really mean a compressed volume or a volume which supports compression of indivual files?
GetVolumeInformation:
Zitat:
The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression, for example, this flag is returned set on a DoubleSpace volume. When compression is volume-based, an entire volume is compressed or not compressed.

The FS_FILE_COMPRESSION flag indicates whether a file system supports file-based compression. When compression is file-based, individual files can be compressed or not compressed.

The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are mutually exclusive. Both bits cannot be returned set.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.164 Beiträge
 
Delphi 12 Athens
 
#3

AW: Is volume compressed?

  Alt 5. Feb 2014, 16:54
MSDN-Library durchsuchenGetVolumeInformation

FS_FILE_COMPRESSION
FS_VOL_IS_COMPRESSED
FSCTL_GET_COMPRESSION
Remarks
...
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#4

Re: Is volume compressed?

  Alt 5. Feb 2014, 17:45
So, I still don't know hot to get information if volome is compressed or not
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: AW: Is volume compressed?

  Alt 5. Feb 2014, 17:54
Do you really mean a compressed volume or a volume which supports compression of indivual files?
So, compressed volume, in properties when checked specified checkbox and then volume showed in blue (usually) - I want to detect this situation
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#6

Re: Is volume compressed?

  Alt 6. Feb 2014, 09:50
None of above flags (flags and flag <> 0) are working, some always returns false, another always true. Any help?
  Mit Zitat antworten Zitat
Der schöne Günther
Online

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#7

AW: Is volume compressed?

  Alt 6. Feb 2014, 11:43
I might be wrong, but I believe there is no clear indication if a volume is either compressed or not compressed at all. We're talking about NTFS, right? I think the FILE_VOLUME_IS_COMPRESSED flag still hails from the time of the FAT file system. Back then, a volume was either entirely compressed ("double space volume") or no compression at all was taking place.

Take a look: Set a volume of yours to "compressed". Create some folders, they're all blue (compressed). Now set a folder to "uncompressed". Your volume will still state "compressed". I believe "volume compression" only means "Default setting for compressing content or not".

Keeping this in mind, this is what I baked together:
Delphi-Quellcode:
procedure TForm18.checkCompression();
const
   // According to http://www.swissdelphicenter.ch/en/showcode.php?id=1053
   COMPRESSION_FORMAT_NONE = 0;
   COMPRESSION_FORMAT_LZNT1 = 2;
   COMPRESSION_FORMAT_DEFAULT = 1;
var
   fileHandle: THandle;
   outBuffer: ^USHORT;
   bufferLength: DWORD;
begin


   // Fetch Handle
   fileHandle := CreateFile(
      'F:\.',
      GENERIC_READ,
      FILE_SHARE_READ,
      nil,
      OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL or FILE_FLAG_BACKUP_SEMANTICS,
      0
   );

   if (fileHandle = INVALID_HANDLE_VALUE) then raise Exception.Create('CreateFile Failed');

   // Init Buffer
   New(outBuffer);

   if not DeviceIoControl(
      fileHandle,
      FSCTL_GET_COMPRESSION,
      nil,
      0,
      outBuffer,
      SizeOf(outBuffer),
      bufferLength,
      nil
   ) then raise Exception.Create('DeviceIoControl failed');

   if (outBuffer^ and COMPRESSION_FORMAT_LZNT1) <> 0 then
      ShowMessage('it is compressed');


end;
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.164 Beiträge
 
Delphi 12 Athens
 
#8

AW: Is volume compressed?

  Alt 6. Feb 2014, 15:40
Zitat:
lpFileSystemFlags [out, optional]

A pointer to a variable that receives flags associated with the specified file system.

This parameter can be one or more of the following flags. However, FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually exclusive.

Remarks

The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression, for example, this flag is returned set on a DoubleSpace volume. When compression is volume-based, an entire volume is compressed or not compressed.

...
Es kann nur Einen geben.



Entweder ist alles immer komprimiert,

oder das Volume unterstützt eine eine Komprimierung.
Und wenn das Volume nun manuell komprimiert wurde, dann ist das andere Flag dennoch nicht aktiv, da nicht das Volume, sondern nur das Root-Verzeichnis komprimiert wurde.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Der schöne Günther
Online

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#9

AW: Is volume compressed?

  Alt 6. Feb 2014, 16:07
Ja, aber er hat ja schon gesagt, dass das Flag trotzdem nicht gesetzt wird, auch wenn man im Explorer für das gesamte Laufwerk das "komprimiert"-Häkchen gesetzt hat. Und das kann ich auch bestätigen. Das war vielleicht unter FAT noch so, aber unter NTFS zwingt kein übergeordnetes Verzeichnis/Laufwerk einen, jetzt gefälligst komprimiert zu sein.

Wie das unter exFat, ReFS und was weiß ich aussieht- Keine Ahnung.
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#10

Re: Is volume compressed?

  Alt 6. Feb 2014, 16:56
Thanks, your explanation is helpful and now I understand more
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:30 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