Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-01-20 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:49 +0300
commitd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (patch)
treec722ed19b844b53042aec0c1d7d2f8381140a5ed /CPP/Windows/FileDevice.cpp
parent804edc5756fede54dbb1aefda6d39d306111938d (diff)
4.44 beta
Diffstat (limited to 'CPP/Windows/FileDevice.cpp')
-rwxr-xr-xCPP/Windows/FileDevice.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/CPP/Windows/FileDevice.cpp b/CPP/Windows/FileDevice.cpp
new file mode 100755
index 00000000..76f1aa7a
--- /dev/null
+++ b/CPP/Windows/FileDevice.cpp
@@ -0,0 +1,49 @@
+// Windows/FileDevice.cpp
+
+#include "StdAfx.h"
+
+#include "FileDevice.h"
+
+namespace NWindows {
+namespace NFile {
+namespace NDevice {
+
+bool CFileBase::GetLengthSmart(UInt64 &length)
+{
+ PARTITION_INFORMATION partInfo;
+ if (GetPartitionInfo(&partInfo))
+ {
+ length = partInfo.PartitionLength.QuadPart;
+ return true;
+ }
+ DISK_GEOMETRY geom;
+ if (!GetGeometry(&geom))
+ if (!GetCdRomGeometry(&geom))
+ return false;
+ length = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector;
+ return true;
+}
+
+bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool CInFile::Open(LPCTSTR fileName)
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
+
+#ifndef _UNICODE
+bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
+ { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
+
+bool CInFile::Open(LPCWSTR fileName)
+ { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
+#endif
+
+bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
+{
+ DWORD processedLoc = 0;
+ bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
+ processedSize = (UInt32)processedLoc;
+ return res;
+}
+
+}}}