#ifndef FS_UTILS_H
#define FS_UTILS_H
#include <FindDirectory.h>
#include <List.h>
#include <ObjectList.h>
#include <Point.h>
#include <StorageDefs.h>
#include <vector>
#include "Model.h"
class BDirectory;
class BEntry;
class BList;
class BFile;
namespace BPrivate {
class BInfoWindow;
class CopyLoopControl {
public:
virtual ~CopyLoopControl();
virtual void Init(uint32 jobKind);
virtual void Init(int32 totalItems, off_t totalSize,
const entry_ref* destDir = NULL,
bool showCount = true);
virtual bool FileError(const char* message,
const char* name, status_t error,
bool allowContinue);
virtual void UpdateStatus(const char* name,
const entry_ref& ref, int32 count,
bool optional = false);
virtual bool CheckUserCanceled();
enum OverwriteMode {
kSkip,
kReplace,
kMerge
};
virtual OverwriteMode OverwriteOnConflict(const BEntry* srcEntry,
const char* destName,
const BDirectory* destDir,
bool srcIsDir, bool dstIsDir);
virtual bool SkipEntry(const BEntry*, bool file);
virtual void ChecksumChunk(const char* block, size_t size);
virtual bool ChecksumFile(const entry_ref*);
virtual bool SkipAttribute(const char* attributeName);
virtual bool PreserveAttribute(const char* attributeName);
};
class TrackerCopyLoopControl : public CopyLoopControl {
public:
TrackerCopyLoopControl();
TrackerCopyLoopControl(uint32 jobKind);
TrackerCopyLoopControl(int32 totalItems,
off_t totalSize);
virtual ~TrackerCopyLoopControl();
virtual void Init(uint32 state);
virtual void Init(int32 totalItems, off_t totalSize,
const entry_ref* destDir = NULL,
bool showCount = true);
virtual bool FileError(const char* message,
const char* name, status_t error,
bool allowContinue);
virtual void UpdateStatus(const char* name,
const entry_ref& ref, int32 count,
bool optional = false);
virtual bool CheckUserCanceled();
virtual bool SkipAttribute(const char* attributeName);
typedef BObjectList<entry_ref, true> EntryList;
void SetSourceList(EntryList* list);
private:
thread_id fThread;
EntryList* fSourceList;
};
#define B_DESKTOP_DIR_NAME "Desktop"
#define B_DISKS_DIR_NAME "Disks"
#define B_TRASH_DIR_NAME "Trash"
#ifndef _IMPEXP_TRACKER
#define _IMPEXP_TRACKER
#endif
_IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*, bool = true);
_IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref, true>* srcList,
BList* pointList);
_IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref, true>* srcList, BEntry*,
uint32 moveMode, BList* pointList = NULL);
_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir,
const char* suffix);
_IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsRootDir(const BEntry*);
_IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref, true>* srcList,
BList* pointList = NULL, bool async = true);
void FSDeleteRefList(BObjectList<entry_ref, true>*, bool, bool confirm = true);
void FSDelete(entry_ref*, bool, bool confirm = true);
void FSRestoreRefList(BObjectList<entry_ref,true >* list, bool async);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application,
const BMessage* refsReceived, bool async, bool openWithOK);
_IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs);
_IMPEXP_TRACKER void FSEmptyTrash();
_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir,
entry_ref* newRef, node_ref* new_node);
_IMPEXP_TRACKER void FSCreateTrashDirs();
_IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume);
_IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir);
_IMPEXP_TRACKER status_t FSRecursiveCalcSize(BInfoWindow*,
CopyLoopControl* loopControl, BDirectory*, off_t* runningSize,
int32* fileCount, int32* dirCount);
bool FSInDeskDir(const entry_ref*);
bool FSIsQueriesDir(const entry_ref*);
bool FSInRootDir(const entry_ref*);
bool FSInTrashDir(const entry_ref*);
bool FSGetPoseLocation(const BNode* node, BPoint* point);
status_t FSSetPoseLocation(BEntry* entry, BPoint point);
status_t FSSetPoseLocation(ino_t destDirInode, BNode* destNode, BPoint point);
status_t FSGetBootDeskDir(BDirectory* deskDir);
status_t FSGetOriginalPath(BEntry* entry, BPath* path);
enum ReadAttrResult {
kReadAttrFailed,
kReadAttrNativeOK,
kReadAttrForeignOK
};
ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName,
const char* foreignAttrName, type_code, off_t, void*, size_t,
void (*swapFunc)(void*) = 0, bool isForeign = false);
ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName,
const char* foreignAttrName, type_code* = NULL, size_t* = NULL);
status_t FSCreateNewFolder(entry_ref*);
status_t FSRecursiveCreateFolder(const char* path);
void FSMakeOriginalName(BString &name, const BDirectory* destDir,
const char* suffix = 0);
status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, entry_ref& _ref);
status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BEntry& _entry);
status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BNode& _node);
status_t TrackerLaunch(const entry_ref* appRef, bool async);
status_t TrackerLaunch(const BMessage* refs, bool async,
bool okToRunOpenWith = true);
status_t TrackerLaunch(const entry_ref* appRef, const BMessage* refs,
bool async, bool okToRunOpenWith = true);
status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true);
bool FSIsDeskDir(const BEntry*);
enum DestructiveAction {
kRename,
kMove
};
bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
DestructiveAction action, bool dontAsk = false,
int32* confirmedAlready = NULL);
status_t EditModelName(const Model* model, const char* name, size_t);
status_t ShouldEditRefName(const entry_ref* ref, const char* name, size_t);
bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel);
_IMPEXP_TRACKER void FSLaunchItem(const entry_ref* appRef,
BMessage* refs = NULL, int32 workspace = -1);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* appRef,
BMessage* refs, int32 workspace, bool asynch);
_IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch,
BMessage* documentEntryRefs);
_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref,
BMessage* listOfRefs);
const uint32 B_USER_MAIL_DIRECTORY = 3500;
const uint32 B_USER_QUERIES_DIRECTORY = 3501;
const uint32 B_USER_PEOPLE_DIRECTORY = 3502;
const uint32 B_USER_DOWNLOADS_DIRECTORY = 3503;
const uint32 B_USER_DESKBAR_APPS_DIRECTORY = 3504;
const uint32 B_USER_DESKBAR_PREFERENCES_DIRECTORY = 3505;
const uint32 B_USER_DESKBAR_DEVELOP_DIRECTORY = 3506;
const uint32 B_BOOT_DISK = 3507;
class WellKnowEntryList {
public:
struct WellKnownEntry {
WellKnownEntry(const node_ref* node, directory_which which,
const char* name)
:
node(*node),
which(which),
name(name)
{
}
WellKnownEntry(const WellKnownEntry &clone)
:
node(clone.node),
which(clone.which),
name(clone.name)
{
}
WellKnownEntry()
{
}
node_ref node;
directory_which which;
BString name;
};
static directory_which Match(const node_ref*);
static const WellKnownEntry* MatchEntry(const node_ref*);
static void Quit();
private:
const WellKnownEntry* MatchEntryCommon(const node_ref*);
WellKnowEntryList();
void AddOne(directory_which, const char* name);
void AddOne(directory_which, const char* path, const char* name);
void AddOne(directory_which, directory_which base,
const char* extension, const char* name);
std::vector<WellKnownEntry> entries;
static WellKnowEntryList* self;
};
#if B_BEOS_VERSION_DANO
#undef _IMPEXP_TRACKER
#endif
}
using namespace BPrivate;
#endif