View Issue Details

IDProjectCategoryView StatusLast Update
0001772Far ManagerViewerpublic2011-10-01 09:58
Reporter2useven10Assigned Tovskirdin 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version3.0 
Target VersionFixed in Version3.0 
Summary0001772: Небольшое причесывание кода CacheRead и его использования во вьювере
DescriptionПросто небольшая чистка кода (изменения для вьювера - част 1)
TagsNo tags attached.
Build2035

Activities

2useven10

2011-05-18 23:55

developer  

Viewer-CacheRead.diff (2,923 bytes)
Index: cache.hpp
===================================================================
--- cache.hpp	(revision 6222)
+++ cache.hpp	(working copy)
@@ -35,9 +35,9 @@
 class CachedRead
 {
 public:
-	CachedRead(File& file, DWORD buff_size=DefaultBufferSize, int alignment=4*1024);
+	CachedRead(File& file);
 	~CachedRead();
-	bool Init(); // file have to be opened already
+	bool AdjustAlignment(); // file have to be opened already
 	bool Read(LPVOID Data, DWORD DataSize, LPDWORD BytesRead);
 	bool FillBuffer();
 	bool Unread(DWORD BytesUnread);
Index: cache.cpp
===================================================================
--- cache.cpp	(revision 6222)
+++ cache.cpp	(working copy)
@@ -35,18 +35,15 @@
 
 #include "cache.hpp"
 
-CachedRead::CachedRead(File& file, DWORD buffer_size, int alignment):
-	Buffer(nullptr),
+CachedRead::CachedRead(File& file):
+	Buffer(static_cast<LPBYTE>(xf_malloc(DefaultBufferSize))),
 	file(file),
 	ReadSize(0),
 	BytesLeft(0),
 	LastPtr(0),
-	BufferSize(buffer_size),
-	Alignment(alignment)
-{
-	if (buffer_size)
-		Buffer = static_cast<LPBYTE>(xf_malloc(buffer_size));
-}
+	BufferSize(DefaultBufferSize),
+	Alignment(512)
+{}
 
 CachedRead::~CachedRead()
 {
@@ -56,30 +53,29 @@
 	}
 }
 
-bool CachedRead::Init()
+bool CachedRead::AdjustAlignment()
 {
 	if (!file.Opened())
 		return false;
 
-	DWORD ret, buff_size = DefaultBufferSize;
-	Alignment = 4 * 1024;
+	DWORD ret, buff_size = BufferSize;
 	DISK_GEOMETRY g;
 
-	if (file.IoControl(IOCTL_DISK_GET_DRIVE_GEOMETRY, nullptr, 0, &g, (DWORD)sizeof(g), &ret, nullptr))
+	if (file.IoControl(IOCTL_DISK_GET_DRIVE_GEOMETRY, nullptr,0, &g,(DWORD)sizeof(g), &ret,nullptr))
 	{
-		if (g.BytesPerSector > 4*1024 && g.BytesPerSector <= 256*1024)
+		if (g.BytesPerSector > 512 && g.BytesPerSector <= 256*1024)
 		{
 			Alignment = (int)g.BytesPerSector;
 			buff_size = 16 * g.BytesPerSector;
 		}
-		file.IoControl(FSCTL_ALLOW_EXTENDED_DASD_IO, nullptr, 0, nullptr, 0, &ret, nullptr);
+		file.IoControl(FSCTL_ALLOW_EXTENDED_DASD_IO, nullptr,0, nullptr,0, &ret,nullptr);
 	}
 
-	if (buff_size != BufferSize)
+	if (buff_size > BufferSize)
 	{
 		if (Buffer)
 			xf_free(Buffer);
-		Buffer = reinterpret_cast<LPBYTE>(xf_malloc(BufferSize = buff_size));
+		Buffer = static_cast<LPBYTE>(xf_malloc(BufferSize = buff_size));
 	}
 
 	Clear();
Index: viewer.cpp
===================================================================
--- viewer.cpp	(revision 6222)
+++ viewer.cpp	(working copy)
@@ -80,7 +80,7 @@
 
 Viewer::Viewer(bool bQuickView, UINT aCodePage):
 	ViOpt(Opt.ViOpt),
-	Reader(ViewFile, 0, 0),
+	Reader(ViewFile),
 	m_bQuickView(bQuickView)
 {
 	_OT(SysLog(L"[%p] Viewer::Viewer()", this));
@@ -278,7 +278,7 @@
 		OpenFailed=true;
 		return FALSE;
 	}
-	Reader.Init();
+	Reader.AdjustAlignment();
 
 	CodePageChangedByUser=FALSE;
 
Viewer-CacheRead.diff (2,923 bytes)

vskirdin

2011-05-19 14:33

administrator   bugnote:0006920

после build 2035

Issue History

Date Modified Username Field Change
2011-05-18 23:55 2useven10 New Issue
2011-05-18 23:55 2useven10 File Added: Viewer-CacheRead.diff
2011-05-19 14:27 vskirdin Assigned To => vskirdin
2011-05-19 14:27 vskirdin Status new => assigned
2011-05-19 14:33 vskirdin Note Added: 0006920
2011-05-19 14:33 vskirdin Status assigned => feedback
2011-10-01 01:22 2useven10 Status feedback => resolved
2011-10-01 09:58 vskirdin Build => 2035
2011-10-01 09:58 vskirdin Status resolved => closed
2011-10-01 09:58 vskirdin Resolution open => fixed
2011-10-01 09:58 vskirdin Fixed in Version => 3.0