Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

CAdvFileAttr Class Reference

#include <AdvFileAttr.h>

Inheritance diagram for CAdvFileAttr:

CWorkQueueItem

Detailed Description

This class manages some special file attributes like Sparse and Compress.
Note:
All the threading code has been rewritten to use my little CWorkQueue and CWorkQueueItem threads. This may have fixed the exit crash issue mentionned below.

Some changes were also done to reduce the clash likelyhood between sparse scanning and downloads. This may have fixed the corruption issue when running sparse scans and downloading concurrently on the same file.

Bug:
Simultaneously sparse-scanning and downloading may cause corruptiion, not yet re-tested with the new implementations.
Warning:
Trying to [de]compress a file while downloading will cause eMule to lock-up - [de]compression makes any further file accesses stall until the operation is completed.
Note:
Complete sources with comments:

[2003-11-05] Finished the single-worker-thread rewriting. Appears to be working very smoothly.


Public Member Functions

 CAdvFileAttr (CFile *file=NULL)
 ~CAdvFileAttr (void)
 Check if there is a worker thread, signal it to terminate and wait.

bool MakeSparse (bool forceScan=false)
bool MakeCompressed (bool makeCompressed=true)
void SetFilePtr (CFile *file=NULL)
bool LoadAttributes (void)
void Cancel (void)
 Tell the thread to terminate by nullifying its structure pointer and pulsing its Cancel Event.

uint32 GetTempFSCappabilities (void)
 Returns the partfile's file system capabilities.

uint32 GetFileAttributes (void)
 Returns the partfile's attributes.

bool isSparse (void)
 Returns true if the file is Sparse.

bool isCompressed (void)
 Returns true if the file is Compressed.

bool isFSSparse (void)
 Returns true if the file system supports Sparse files.

bool isFSCompressed (void)
 Returns true if the file system supports Compressed files.

bool isBusy (void)
 Returns true if the worker thread is running.

bool isCancel (void)
 Returns true if the worker thread is running.

void ThreadWork (void)
 Dispatches the queued workloads.


Private Types

enum  { TOps_Nothing, TOps_Compress, TOps_Sparse, TOps_Cancel }
 Tells ThreadWork what to do.


Private Member Functions

bool WorkSparse (void)
void WorkCompress (void)
void QueueDelCB (void)
 Workload removal from queue callback.


Private Attributes

enum CAdvFileAttr:: { ... }  m_LastOp
 Tells ThreadWork what to do.

uint32 m_FileAttributes
 Holds the file attributes from the last time attributes have been loaded.

uint32 m_TempFSCapabilities
 Holds the file system capabilities from the last time capabilities have been loaded.

CFile * m_pCFile
 Pointer to the file that goes with this instance.


Static Private Attributes

CWorkQueue m_WorkQueue
 Counts the number of threads that have been started.


Constructor & Destructor Documentation

CAdvFileAttr::CAdvFileAttr CFile *  file = NULL  ) 
 

On creation, load the file's attributes if a CFile was provided.

Parameters:
file Pointer to a file object to associate with this instance.


Member Function Documentation

bool CAdvFileAttr::LoadAttributes void   ) 
 

Reloads file attributes

Returns:
True on success.

bool CAdvFileAttr::MakeCompressed bool  makeCompressed = true  ) 
 

Scans the file for sparseness.

Returns:
True if the thread started.

bool CAdvFileAttr::MakeSparse bool  forceScan = false  ) 
 

Makes a the associated file sparse if possible.

Parameters:
forceScan If true, force re-scanning of the file to extract sparseness.
Returns:
True if the file was successfully made sparse and the scanning thread started.

void CAdvFileAttr::SetFilePtr CFile *  file = NULL  ) 
 

Sets the CFile associated to this instance and loads the file system capabilities for that file.

Parameters:
file Pointer to the parent class' m_hpartfile.

void CAdvFileAttr::WorkCompress void   )  [private]
 

Set the compression attribute from a thread to avoid stalling the main GUI.

Warning:
While changing attributes, all writes (and maybe reads) on the file become blocking calls.

bool CAdvFileAttr::WorkSparse void   )  [private]
 

Scans the file for sparseness.

Bug:
Quitting while a sparse is under way will cause some exceptions and memory leaks even though the thread should quit pretty quickly.
Returns:
True on success.


The documentation for this class was generated from the following files:
Generated on Wed Nov 5 05:48:09 2003 for Moonlight's eMule Tweaks Documentation by doxygen 1.3.4