* 80 chars/line limit cleanup
* Fixed one more occurance of "dos" filesystem check. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35113 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0bf7f1f8cd
commit
8aad948744
@ -18,18 +18,18 @@ and shall be included in all copies or substantial portions of the Software.
|
|||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
this Software without prior written authorization from Be Incorporated.
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
|
||||||
of Be Incorporated in the United States and other countries. Other brand product
|
trademarks of Be Incorporated in the United States and other countries. Other
|
||||||
names are registered trademarks or trademarks of their respective holders.
|
brand product names are registered trademarks or trademarks of their
|
||||||
All rights reserved.
|
respective holders. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Tracker file system calls.
|
// Tracker file system calls.
|
||||||
@ -136,8 +136,8 @@ status_t empty_trash(void *);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const char *kDeleteConfirmationStr = "Are you sure you want to delete the selected "
|
const char *kDeleteConfirmationStr = "Are you sure you want to delete the "
|
||||||
"item(s)? This operation cannot be reverted.";
|
"selected item(s)? This operation cannot be reverted.";
|
||||||
|
|
||||||
const char *kReplaceStr = "You are trying to replace the item:\n"
|
const char *kReplaceStr = "You are trying to replace the item:\n"
|
||||||
"\t%s%s\n"
|
"\t%s%s\n"
|
||||||
@ -145,25 +145,31 @@ const char *kReplaceStr = "You are trying to replace the item:\n"
|
|||||||
"\t%s%s\n\n"
|
"\t%s%s\n\n"
|
||||||
"Would you like to replace it with the one you are %s?";
|
"Would you like to replace it with the one you are %s?";
|
||||||
|
|
||||||
const char *kDirectoryReplaceStr = "An item named \"%s\" already exists in this folder, and may contain\n"
|
const char *kDirectoryReplaceStr = "An item named \"%s\" already exists in "
|
||||||
"items with the same names. Would you like to replace them with those contained in the folder you are %s?";
|
"this folder, and may contain\nitems with the same names. Would you like "
|
||||||
|
"to replace them with those contained in the folder you are %s?";
|
||||||
|
|
||||||
const char *kSymLinkReplaceStr = "An item named \"%s\" already exists in this folder. "
|
const char *kSymLinkReplaceStr = "An item named \"%s\" already exists in this "
|
||||||
"Would you like to replace it with the symbolic link you are creating?";
|
"folder. Would you like to replace it with the symbolic link you are "
|
||||||
|
"creating?";
|
||||||
|
|
||||||
const char *kNoFreeSpace = "Sorry, there is not enough free space on the destination "
|
const char *kNoFreeSpace = "Sorry, there is not enough free space on the "
|
||||||
"volume to copy the selection.";
|
"destination volume to copy the selection.";
|
||||||
|
|
||||||
const char *kFileErrorString = "Error copying file \"%s\":\n\t%s\n\nWould you like to continue?";
|
const char *kFileErrorString = "Error copying file \"%s\":\n\t%s\n\nWould "
|
||||||
const char *kFolderErrorString = "Error copying folder \"%s\":\n\t%s\n\nWould you like to continue?";
|
"you like to continue?";
|
||||||
const char *kFileDeleteErrorString = "There was an error deleting \"%s\":\n\t%s";
|
const char *kFolderErrorString = "Error copying folder \"%s\":\n\t%s\n\nWould "
|
||||||
|
"you like to continue?";
|
||||||
|
const char *kFileDeleteErrorString = "There was an error deleting \"%s\""
|
||||||
|
":\n\t%s";
|
||||||
const char *kReplaceManyStr = "Some items already exist in this folder with "
|
const char *kReplaceManyStr = "Some items already exist in this folder with "
|
||||||
"the same names as the items you are %s.\n \nWould you like to replace them "
|
"the same names as the items you are %s.\n \nWould you like to replace "
|
||||||
"with the ones you are %s or be prompted for each one?";
|
"them with the ones you are %s or be prompted for each one?";
|
||||||
|
|
||||||
const char *kFindAlternativeStr = "Would you like to find some other suitable application?";
|
const char *kFindAlternativeStr = "Would you like to find some other suitable "
|
||||||
const char *kFindApplicationStr = "Would you like to find a suitable application to "
|
"application?";
|
||||||
"open the file?";
|
const char *kFindApplicationStr = "Would you like to find a suitable "
|
||||||
|
"application to open the file?";
|
||||||
|
|
||||||
// Skip these attributes when copying in Tracker
|
// Skip these attributes when copying in Tracker
|
||||||
const char *kSkipAttributes[] = {
|
const char *kSkipAttributes[] = {
|
||||||
@ -215,6 +221,7 @@ TrackerCopyLoopControl::TrackerCopyLoopControl(thread_id thread)
|
|||||||
fThread(thread),
|
fThread(thread),
|
||||||
fSourceList(NULL)
|
fSourceList(NULL)
|
||||||
{
|
{
|
||||||
|
// TODO: Move all gStatusWindow handling here (CreateItem()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -224,6 +231,7 @@ TrackerCopyLoopControl::TrackerCopyLoopControl(thread_id thread,
|
|||||||
fThread(thread),
|
fThread(thread),
|
||||||
fSourceList(NULL)
|
fSourceList(NULL)
|
||||||
{
|
{
|
||||||
|
// TODO: Move all gStatusWindow handling here (CreateItem()...)
|
||||||
if (gStatusWindow)
|
if (gStatusWindow)
|
||||||
gStatusWindow->InitStatusItem(thread, totalItems, totalItems);
|
gStatusWindow->InitStatusItem(thread, totalItems, totalItems);
|
||||||
}
|
}
|
||||||
@ -231,6 +239,9 @@ TrackerCopyLoopControl::TrackerCopyLoopControl(thread_id thread,
|
|||||||
|
|
||||||
TrackerCopyLoopControl::~TrackerCopyLoopControl()
|
TrackerCopyLoopControl::~TrackerCopyLoopControl()
|
||||||
{
|
{
|
||||||
|
// TODO: Move all gStatusWindow handling here
|
||||||
|
// if (gStatusWindow)
|
||||||
|
// gStatusWindow->RemoveStatusItem(fThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -466,9 +477,10 @@ FSDelete(entry_ref *ref, bool async, bool confirm)
|
|||||||
void
|
void
|
||||||
FSDeleteRefList(BObjectList<entry_ref> *list, bool async, bool confirm)
|
FSDeleteRefList(BObjectList<entry_ref> *list, bool async, bool confirm)
|
||||||
{
|
{
|
||||||
if (async)
|
if (async) {
|
||||||
LaunchInNewThread("DeleteTask", B_NORMAL_PRIORITY, _DeleteTask, list, confirm);
|
LaunchInNewThread("DeleteTask", B_NORMAL_PRIORITY, _DeleteTask, list,
|
||||||
else
|
confirm);
|
||||||
|
} else
|
||||||
_DeleteTask(list, confirm);
|
_DeleteTask(list, confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,9 +488,10 @@ FSDeleteRefList(BObjectList<entry_ref> *list, bool async, bool confirm)
|
|||||||
void
|
void
|
||||||
FSRestoreRefList(BObjectList<entry_ref> *list, bool async)
|
FSRestoreRefList(BObjectList<entry_ref> *list, bool async)
|
||||||
{
|
{
|
||||||
if (async)
|
if (async) {
|
||||||
LaunchInNewThread("RestoreTask", B_NORMAL_PRIORITY, _RestoreTask, list);
|
LaunchInNewThread("RestoreTask", B_NORMAL_PRIORITY, _RestoreTask,
|
||||||
else
|
list);
|
||||||
|
} else
|
||||||
_RestoreTask(list);
|
_RestoreTask(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +552,8 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *action,
|
|||||||
|
|
||||||
if (DirectoryMatchesOrContains(entry, B_BEOS_DIRECTORY)) {
|
if (DirectoryMatchesOrContains(entry, B_BEOS_DIRECTORY)) {
|
||||||
warning = "If you %s the system folder or its contents, you "
|
warning = "If you %s the system folder or its contents, you "
|
||||||
"won't be able to boot " OS_NAME "! Are you sure you want to do this? "
|
"won't be able to boot " OS_NAME "! Are you sure you want to do "
|
||||||
"To %s the system folder or its contents anyway, hold down "
|
"this? To %s the system folder or its contents anyway, hold down "
|
||||||
"the Shift key and click \"Do it\".";
|
"the Shift key and click \"Do it\".";
|
||||||
} else if (DirectoryMatches(entry, B_USER_DIRECTORY)) {
|
} else if (DirectoryMatches(entry, B_USER_DIRECTORY)) {
|
||||||
warning = "If you %s the home folder, " OS_NAME " may not "
|
warning = "If you %s the home folder, " OS_NAME " may not "
|
||||||
@ -550,8 +563,10 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *action,
|
|||||||
} else if (DirectoryMatchesOrContains(entry, B_USER_CONFIG_DIRECTORY)
|
} else if (DirectoryMatchesOrContains(entry, B_USER_CONFIG_DIRECTORY)
|
||||||
|| DirectoryMatchesOrContains(entry, B_COMMON_SETTINGS_DIRECTORY)) {
|
|| DirectoryMatchesOrContains(entry, B_COMMON_SETTINGS_DIRECTORY)) {
|
||||||
|
|
||||||
if (DirectoryMatchesOrContains(entry, "beos_mime", B_USER_SETTINGS_DIRECTORY)
|
if (DirectoryMatchesOrContains(entry, "beos_mime",
|
||||||
|| DirectoryMatchesOrContains(entry, "beos_mime", B_COMMON_SETTINGS_DIRECTORY)) {
|
B_USER_SETTINGS_DIRECTORY)
|
||||||
|
|| DirectoryMatchesOrContains(entry, "beos_mime",
|
||||||
|
B_COMMON_SETTINGS_DIRECTORY)) {
|
||||||
warning = "If you %s the mime settings, " OS_NAME " may not "
|
warning = "If you %s the mime settings, " OS_NAME " may not "
|
||||||
"behave properly! Are you sure you want to do this? "
|
"behave properly! Are you sure you want to do this? "
|
||||||
"To %s the mime settings anyway, click \"Do it\".";
|
"To %s the mime settings anyway, click \"Do it\".";
|
||||||
@ -584,8 +599,10 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *action,
|
|||||||
char buffer[256];
|
char buffer[256];
|
||||||
sprintf(buffer, warning, action, action);
|
sprintf(buffer, warning, action, action);
|
||||||
|
|
||||||
if ((new OverrideAlert("", buffer, "Do it", (requireOverride ? B_SHIFT_KEY : 0),
|
if ((new OverrideAlert("", buffer, "Do it", (requireOverride
|
||||||
"Cancel", 0, NULL, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 1) {
|
? B_SHIFT_KEY : 0),
|
||||||
|
"Cancel", 0, NULL, 0, B_WIDTH_AS_USUAL,
|
||||||
|
B_WARNING_ALERT))->Go() == 1) {
|
||||||
if (confirmedAlready)
|
if (confirmedAlready)
|
||||||
*confirmedAlready = kNotConfirmed;
|
*confirmedAlready = kNotConfirmed;
|
||||||
return false;
|
return false;
|
||||||
@ -641,8 +658,10 @@ InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
if (moveMode == kMoveSelectionTo
|
if (moveMode == kMoveSelectionTo
|
||||||
&& !ConfirmChangeIfWellKnownDirectory(&entry, "move", false, &askOnceOnly))
|
&& !ConfirmChangeIfWellKnownDirectory(&entry, "move", false,
|
||||||
|
&askOnceOnly)) {
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preflightNameCheck) {
|
if (preflightNameCheck) {
|
||||||
@ -652,7 +671,8 @@ InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
|
|||||||
*preflightResult = kPrompt;
|
*preflightResult = kPrompt;
|
||||||
*collisionCount = 0;
|
*collisionCount = 0;
|
||||||
|
|
||||||
*preflightResult = PreFlightNameCheck(srcList, destDir, collisionCount, moveMode);
|
*preflightResult = PreFlightNameCheck(srcList, destDir, collisionCount,
|
||||||
|
moveMode);
|
||||||
if (*preflightResult == kCanceled) // user canceled
|
if (*preflightResult == kCanceled) // user canceled
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@ -810,8 +830,9 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList,
|
|||||||
thread_id thread = find_thread(NULL);
|
thread_id thread = find_thread(NULL);
|
||||||
ConflictCheckResult conflictCheckResult = kPrompt;
|
ConflictCheckResult conflictCheckResult = kPrompt;
|
||||||
int32 collisionCount = 0;
|
int32 collisionCount = 0;
|
||||||
status_t result = InitCopy(moveMode, srcList, thread, &volume, destDirToCheck,
|
status_t result = InitCopy(moveMode, srcList, thread, &volume,
|
||||||
&destRef, needPreflightNameCheck, needSizeCalculation, &collisionCount, &conflictCheckResult);
|
destDirToCheck, &destRef, needPreflightNameCheck, needSizeCalculation,
|
||||||
|
&collisionCount, &conflictCheckResult);
|
||||||
|
|
||||||
TrackerCopyLoopControl loopControl(thread);
|
TrackerCopyLoopControl loopControl(thread);
|
||||||
loopControl.SetSourceList(srcList);
|
loopControl.SetSourceList(srcList);
|
||||||
@ -833,8 +854,8 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList,
|
|||||||
volume.SetTo(srcRef->device);
|
volume.SetTo(srcRef->device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle case where item is dropped into folder it already lives in
|
// handle case where item is dropped into folder it already lives
|
||||||
// which could happen if dragging from a query window
|
// in which could happen if dragging from a query window
|
||||||
if (moveMode != kCreateLink
|
if (moveMode != kCreateLink
|
||||||
&& moveMode != kCreateRelativeLink
|
&& moveMode != kCreateRelativeLink
|
||||||
&& moveMode != kDuplicateSelection
|
&& moveMode != kDuplicateSelection
|
||||||
@ -865,8 +886,8 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList,
|
|||||||
result = MoveEntryToTrash(&sourceEntry, loc, undo);
|
result = MoveEntryToTrash(&sourceEntry, loc, undo);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
BString error;
|
BString error;
|
||||||
error << "Error moving \"" << srcRef->name << "\" to Trash. ("
|
error << "Error moving \"" << srcRef->name
|
||||||
<< strerror(result) << ")";
|
<< "\" to Trash. (" << strerror(result) << ")";
|
||||||
BAlert *alert = new BAlert("", error.String(), "Cancel",
|
BAlert *alert = new BAlert("", error.String(), "Cancel",
|
||||||
0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
@ -908,8 +929,8 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList,
|
|||||||
if (pointList)
|
if (pointList)
|
||||||
loc = (BPoint*)pointList->ItemAt(i);
|
loc = (BPoint*)pointList->ItemAt(i);
|
||||||
|
|
||||||
result = MoveItem(&sourceEntry, &destDir, loc, moveMode, NULL, undo,
|
result = MoveItem(&sourceEntry, &destDir, loc, moveMode, NULL,
|
||||||
&loopControl);
|
undo, &loopControl);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -925,6 +946,7 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList,
|
|||||||
delete pointList;
|
delete pointList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move this into TrackerCopyLoopControl destructor
|
||||||
if (gStatusWindow)
|
if (gStatusWindow)
|
||||||
gStatusWindow->RemoveStatusItem(thread);
|
gStatusWindow->RemoveStatusItem(thread);
|
||||||
|
|
||||||
@ -933,7 +955,8 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList,
|
|||||||
|
|
||||||
class FailWithAlert {
|
class FailWithAlert {
|
||||||
public:
|
public:
|
||||||
static void FailOnError(status_t error, const char *string, const char *name = NULL)
|
static void FailOnError(status_t error, const char *string,
|
||||||
|
const char *name = NULL)
|
||||||
{
|
{
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
throw FailWithAlert(error, string, name);
|
throw FailWithAlert(error, string, name);
|
||||||
@ -1025,11 +1048,13 @@ CopyFile(BEntry *srcFile, StatStruct *srcStat, BDirectory *destDir,
|
|||||||
throw (status_t)err;
|
throw (status_t)err;
|
||||||
|
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
if (!loopControl->FileError(kFileErrorString, destName, err, true))
|
if (!loopControl->FileError(kFileErrorString, destName, err,
|
||||||
|
true)) {
|
||||||
throw (status_t)err;
|
throw (status_t)err;
|
||||||
else
|
} else {
|
||||||
// user selected continue in spite of error, update status bar
|
// user selected continue in spite of error, update status bar
|
||||||
loopControl->UpdateStatus(NULL, ref, (int32)srcStat->st_size);
|
loopControl->UpdateStatus(NULL, ref, (int32)srcStat->st_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1047,7 +1072,7 @@ CreateFileSystemCompatibleName(const BDirectory *destDir, char *destName)
|
|||||||
fs_info info;
|
fs_info info;
|
||||||
if (target.GetRef(&targetRef) == B_OK
|
if (target.GetRef(&targetRef) == B_OK
|
||||||
&& fs_stat_dev(targetRef.device, &info) == B_OK
|
&& fs_stat_dev(targetRef.device, &info) == B_OK
|
||||||
&& !strcmp(info.fsh_name, "dos")) {
|
&& !strcmp(info.fsh_name, "fat")) {
|
||||||
bool wasInvalid = false;
|
bool wasInvalid = false;
|
||||||
|
|
||||||
// it's a FAT32 file system, now check the name
|
// it's a FAT32 file system, now check the name
|
||||||
@ -1120,7 +1145,8 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir,
|
|||||||
// File bigger than the buffer size: determine an optimal buffer size
|
// File bigger than the buffer size: determine an optimal buffer size
|
||||||
system_info sinfo;
|
system_info sinfo;
|
||||||
get_system_info(&sinfo);
|
get_system_info(&sinfo);
|
||||||
size_t freesize = static_cast<size_t>((sinfo.max_pages - sinfo.used_pages) * B_PAGE_SIZE);
|
size_t freesize = static_cast<size_t>(
|
||||||
|
(sinfo.max_pages - sinfo.used_pages) * B_PAGE_SIZE);
|
||||||
bufsize = freesize / 4; // take 1/4 of RAM max
|
bufsize = freesize / 4; // take 1/4 of RAM max
|
||||||
bufsize -= bufsize % (16 * 1024); // Round to 16 KB boundaries
|
bufsize -= bufsize % (16 * 1024); // Round to 16 KB boundaries
|
||||||
if (bufsize < kMinBufferSize) // at least kMinBufferSize
|
if (bufsize < kMinBufferSize) // at least kMinBufferSize
|
||||||
@ -1131,9 +1157,11 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir,
|
|||||||
|
|
||||||
BFile destFile(destDir, destName, O_RDWR | O_CREAT);
|
BFile destFile(destDir, destName, O_RDWR | O_CREAT);
|
||||||
#ifdef _SILENTLY_CORRECT_FILE_NAMES
|
#ifdef _SILENTLY_CORRECT_FILE_NAMES
|
||||||
if ((destFile.InitCheck() == B_BAD_VALUE || destFile.InitCheck() == B_NOT_ALLOWED)
|
if ((destFile.InitCheck() == B_BAD_VALUE
|
||||||
&& CreateFileSystemCompatibleName(destDir, destName))
|
|| destFile.InitCheck() == B_NOT_ALLOWED)
|
||||||
|
&& CreateFileSystemCompatibleName(destDir, destName)) {
|
||||||
destFile.SetTo(destDir, destName, B_CREATE_FILE | B_READ_WRITE);
|
destFile.SetTo(destDir, destName, B_CREATE_FILE | B_READ_WRITE);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThrowOnInitCheckError(&destFile);
|
ThrowOnInitCheckError(&destFile);
|
||||||
@ -1165,8 +1193,8 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir,
|
|||||||
if (bytes > 0) {
|
if (bytes > 0) {
|
||||||
ssize_t updateBytes = 0;
|
ssize_t updateBytes = 0;
|
||||||
if (bytes > 32 * 1024) {
|
if (bytes > 32 * 1024) {
|
||||||
// when copying large chunks, update after read and after write
|
// when copying large chunks, update after read and after
|
||||||
// to get better update granularity
|
// write to get better update granularity
|
||||||
updateBytes = bytes / 2;
|
updateBytes = bytes / 2;
|
||||||
loopControl->UpdateStatus(NULL, ref, updateBytes, true);
|
loopControl->UpdateStatus(NULL, ref, updateBytes, true);
|
||||||
}
|
}
|
||||||
@ -1177,13 +1205,15 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir,
|
|||||||
if (result != bytes)
|
if (result != bytes)
|
||||||
throw (status_t)B_ERROR;
|
throw (status_t)B_ERROR;
|
||||||
|
|
||||||
loopControl->UpdateStatus(NULL, ref, bytes - updateBytes, true);
|
loopControl->UpdateStatus(NULL, ref, bytes - updateBytes,
|
||||||
} else if (bytes < 0)
|
true);
|
||||||
|
} else if (bytes < 0) {
|
||||||
// read error
|
// read error
|
||||||
throw (status_t)bytes;
|
throw (status_t)bytes;
|
||||||
else
|
} else {
|
||||||
// we are done
|
// we are done
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyAttributes(loopControl, &srcFile, &destFile, buffer, bufsize);
|
CopyAttributes(loopControl, &srcFile, &destFile, buffer, bufsize);
|
||||||
@ -1213,8 +1243,8 @@ LowLevelCopy(BEntry *srcEntry, StatStruct *srcStat, BDirectory *destDir,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CopyAttributes(CopyLoopControl *control, BNode *srcNode, BNode *destNode, void *buffer,
|
CopyAttributes(CopyLoopControl *control, BNode *srcNode, BNode *destNode,
|
||||||
size_t bufsize)
|
void *buffer, size_t bufsize)
|
||||||
{
|
{
|
||||||
// ToDo:
|
// ToDo:
|
||||||
// Add error checking
|
// Add error checking
|
||||||
@ -1260,7 +1290,8 @@ CopyAttributes(CopyLoopControl *control, BNode *srcNode, BNode *destNode, void *
|
|||||||
if (bytes <= 0)
|
if (bytes <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
destNode->WriteAttr(name, info.type, offset, buffer, (size_t)bytes);
|
destNode->WriteAttr(name, info.type, offset, buffer,
|
||||||
|
(size_t)bytes);
|
||||||
|
|
||||||
numToRead -= bytes;
|
numToRead -= bytes;
|
||||||
}
|
}
|
||||||
@ -1337,8 +1368,10 @@ CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
if (!loopControl->FileError(kFolderErrorString, destName, err, true))
|
if (!loopControl->FileError(kFolderErrorString, destName, err,
|
||||||
|
true)) {
|
||||||
throw err;
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
// will allow rest of copy to continue
|
// will allow rest of copy to continue
|
||||||
return;
|
return;
|
||||||
@ -1346,7 +1379,8 @@ CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
if (createDirectory && err == B_OK && (buffer = (char*)malloc(32768)) != 0) {
|
if (createDirectory && err == B_OK
|
||||||
|
&& (buffer = (char*)malloc(32768)) != 0) {
|
||||||
CopyAttributes(loopControl, &srcDir, &newDir, buffer, 32768);
|
CopyAttributes(loopControl, &srcDir, &newDir, buffer, 32768);
|
||||||
// don't copy original pose location if new location passed
|
// don't copy original pose location if new location passed
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@ -1373,11 +1407,13 @@ CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl,
|
|||||||
|
|
||||||
// entry is a mount point, do not copy it
|
// entry is a mount point, do not copy it
|
||||||
if (statbuf.st_dev != sourceDeviceID) {
|
if (statbuf.st_dev != sourceDeviceID) {
|
||||||
PRINT(("Avoiding mount point %d, %d \n", statbuf.st_dev, sourceDeviceID));
|
PRINT(("Avoiding mount point %d, %d \n", statbuf.st_dev,
|
||||||
|
sourceDeviceID));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyFolder(&entry, &newDir, loopControl, 0, false, undo, removeSource);
|
CopyFolder(&entry, &newDir, loopControl, 0, false, undo,
|
||||||
|
removeSource);
|
||||||
if (removeSource)
|
if (removeSource)
|
||||||
FSDeleteFolder(&entry, loopControl, true, true, false);
|
FSDeleteFolder(&entry, loopControl, true, true, false);
|
||||||
} else {
|
} else {
|
||||||
@ -1394,7 +1430,8 @@ CopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
RecursiveMove(BEntry *entry, BDirectory *destDir, CopyLoopControl* loopControl)
|
RecursiveMove(BEntry *entry, BDirectory *destDir,
|
||||||
|
CopyLoopControl* loopControl)
|
||||||
{
|
{
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
if (entry->GetName(name) == B_OK) {
|
if (entry->GetName(name) == B_OK) {
|
||||||
@ -1528,13 +1565,18 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode,
|
|||||||
if (moveMode == kCreateLink)
|
if (moveMode == kCreateLink)
|
||||||
err = destDir->CreateSymLink(name, path.Path(), &link);
|
err = destDir->CreateSymLink(name, path.Path(), &link);
|
||||||
|
|
||||||
if (err == B_UNSUPPORTED)
|
if (err == B_UNSUPPORTED) {
|
||||||
throw FailWithAlert(err, "The target disk does not support creating links.", NULL);
|
throw FailWithAlert(err, "The target disk does not support "
|
||||||
|
"creating links.", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
FailWithAlert::FailOnError(err, "Error creating link to \"%s\".", ref.name);
|
FailWithAlert::FailOnError(err, "Error creating link to \"%s\".",
|
||||||
|
ref.name);
|
||||||
|
|
||||||
if (loc && loc != (BPoint *)-1)
|
if (loc && loc != (BPoint *)-1) {
|
||||||
link.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, sizeof(PoseInfo));
|
link.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo,
|
||||||
|
sizeof(PoseInfo));
|
||||||
|
}
|
||||||
|
|
||||||
BNodeInfo nodeInfo(&link);
|
BNodeInfo nodeInfo(&link);
|
||||||
nodeInfo.SetType(B_LINK_MIMETYPE);
|
nodeInfo.SetType(B_LINK_MIMETYPE);
|
||||||
@ -1569,7 +1611,8 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode,
|
|||||||
} catch (MoveError error) {
|
} catch (MoveError error) {
|
||||||
BString errorString;
|
BString errorString;
|
||||||
errorString << "Error moving \"" << ref.name << '"';
|
errorString << "Error moving \"" << ref.name << '"';
|
||||||
(new BAlert("", errorString.String(), "OK", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
(new BAlert("", errorString.String(), "OK", 0, 0, B_WIDTH_AS_USUAL,
|
||||||
|
B_WARNING_ALERT))->Go();
|
||||||
return error.fError;
|
return error.fError;
|
||||||
} catch (FailWithAlert error) {
|
} catch (FailWithAlert error) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
@ -1577,7 +1620,8 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode,
|
|||||||
sprintf(buffer, error.fString, error.fName);
|
sprintf(buffer, error.fString, error.fName);
|
||||||
else
|
else
|
||||||
strcpy(buffer, error.fString);
|
strcpy(buffer, error.fString);
|
||||||
(new BAlert("", buffer, "OK", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
(new BAlert("", buffer, "OK", 0, 0, B_WIDTH_AS_USUAL,
|
||||||
|
B_WARNING_ALERT))->Go();
|
||||||
|
|
||||||
return error.fError;
|
return error.fError;
|
||||||
}
|
}
|
||||||
@ -1589,21 +1633,20 @@ MoveItem(BEntry *entry, BDirectory *destDir, BPoint *loc, uint32 moveMode,
|
|||||||
void
|
void
|
||||||
FSDuplicate(BObjectList<entry_ref> *srcList, BList *pointList)
|
FSDuplicate(BObjectList<entry_ref> *srcList, BList *pointList)
|
||||||
{
|
{
|
||||||
LaunchInNewThread("DupTask", B_NORMAL_PRIORITY, MoveTask, srcList, (BEntry *)NULL,
|
LaunchInNewThread("DupTask", B_NORMAL_PRIORITY, MoveTask, srcList,
|
||||||
pointList, kDuplicateSelection);
|
(BEntry *)NULL, pointList, kDuplicateSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
status_t
|
status_t
|
||||||
FSCopyFolder(BEntry *srcEntry, BDirectory *destDir, CopyLoopControl *loopControl,
|
FSCopyFolder(BEntry *srcEntry, BDirectory *destDir,
|
||||||
BPoint *loc, bool makeOriginalName)
|
CopyLoopControl *loopControl, BPoint *loc, bool makeOriginalName)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName);
|
CopyFolder(srcEntry, destDir, loopControl, loc, makeOriginalName);
|
||||||
} catch (status_t error) {
|
catch (status_t error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -1634,12 +1677,14 @@ FSCopyAttributesAndStats(BNode *srcNode, BNode *destNode)
|
|||||||
if (chunkSize > 1024)
|
if (chunkSize > 1024)
|
||||||
chunkSize = 1024;
|
chunkSize = 1024;
|
||||||
|
|
||||||
bytes = srcNode->ReadAttr(name, info.type, offset, buffer, chunkSize);
|
bytes = srcNode->ReadAttr(name, info.type, offset, buffer,
|
||||||
|
chunkSize);
|
||||||
|
|
||||||
if (bytes <= 0)
|
if (bytes <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
destNode->WriteAttr(name, info.type, offset, buffer, (size_t)bytes);
|
destNode->WriteAttr(name, info.type, offset, buffer,
|
||||||
|
(size_t)bytes);
|
||||||
|
|
||||||
numToRead -= bytes;
|
numToRead -= bytes;
|
||||||
}
|
}
|
||||||
@ -1665,7 +1710,8 @@ FSCopyFile(BEntry* srcFile, StatStruct *srcStat, BDirectory* destDir,
|
|||||||
CopyLoopControl *loopControl, BPoint *loc, bool makeOriginalName)
|
CopyLoopControl *loopControl, BPoint *loc, bool makeOriginalName)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
CopyFile(srcFile, srcStat, destDir, loopControl, loc, makeOriginalName);
|
CopyFile(srcFile, srcStat, destDir, loopControl, loc,
|
||||||
|
makeOriginalName);
|
||||||
} catch (status_t error) {
|
} catch (status_t error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -1708,7 +1754,8 @@ MoveEntryToTrash(BEntry *entry, BPoint *loc, Undo &undo)
|
|||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
volume.GetName(name);
|
volume.GetName(name);
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
sprintf(buffer, "Cannot unmount the boot volume \"%s\".", name);
|
sprintf(buffer, "Cannot unmount the boot volume \"%s\".",
|
||||||
|
name);
|
||||||
BAlert *alert = new BAlert("", buffer, "Cancel", 0, 0,
|
BAlert *alert = new BAlert("", buffer, "Cancel", 0, 0,
|
||||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
@ -1814,7 +1861,8 @@ PreFlightNameCheck(BObjectList<entry_ref> *srcList, const BDirectory *destDir,
|
|||||||
// prompt user only if there is more than one collision, otherwise the
|
// prompt user only if there is more than one collision, otherwise the
|
||||||
// single collision case will be handled as a "Prompt" case by CheckName
|
// single collision case will be handled as a "Prompt" case by CheckName
|
||||||
if (*collisionCount > 1) {
|
if (*collisionCount > 1) {
|
||||||
const char *verb = (moveMode == kMoveSelectionTo) ? "moving" : "copying";
|
const char *verb = (moveMode == kMoveSelectionTo) ? "moving"
|
||||||
|
: "copying";
|
||||||
char replaceMsg[256];
|
char replaceMsg[256];
|
||||||
sprintf(replaceMsg, kReplaceManyStr, verb, verb);
|
sprintf(replaceMsg, kReplaceManyStr, verb, verb);
|
||||||
|
|
||||||
@ -1852,8 +1900,9 @@ FileStatToString(StatStruct *stat, char *buffer, int32 length)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
CheckName(uint32 moveMode, const BEntry *sourceEntry,
|
||||||
bool multipleCollisions, ConflictCheckResult &replaceAll)
|
const BDirectory *destDir, bool multipleCollisions,
|
||||||
|
ConflictCheckResult &replaceAll)
|
||||||
{
|
{
|
||||||
if (moveMode == kDuplicateSelection)
|
if (moveMode == kDuplicateSelection)
|
||||||
// when duplicating, we will never have a conflict
|
// when duplicating, we will never have a conflict
|
||||||
@ -1873,7 +1922,8 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
|||||||
|
|
||||||
if (moveMode != kCreateLink
|
if (moveMode != kCreateLink
|
||||||
&& moveMode != kCreateRelativeLink
|
&& moveMode != kCreateRelativeLink
|
||||||
&& (srcDirectory == *destDir || srcDirectory.Contains(&destEntry))) {
|
&& (srcDirectory == *destDir
|
||||||
|
|| srcDirectory.Contains(&destEntry))) {
|
||||||
(new BAlert("", "You can't move a folder into itself "
|
(new BAlert("", "You can't move a folder into itself "
|
||||||
"or any of its own sub-folders.", "OK", 0, 0,
|
"or any of its own sub-folders.", "OK", 0, 0,
|
||||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
||||||
@ -1881,7 +1931,7 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FSIsTrashDir(sourceEntry) && moveMode != kCreateLink
|
if (FSIsTrashDir(sourceEntry) && moveMode != kCreateLink
|
||||||
&& moveMode != kCreateRelativeLink) {
|
&& moveMode != kCreateRelativeLink) {
|
||||||
(new BAlert("", "You can't move or copy the trash.",
|
(new BAlert("", "You can't move or copy the trash.",
|
||||||
"OK", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
"OK", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
||||||
@ -1914,14 +1964,16 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure user isn't trying to replace a file with folder or vice versa.
|
||||||
if (moveMode != kCreateLink
|
if (moveMode != kCreateLink
|
||||||
&& moveMode != kCreateRelativeLink
|
&& moveMode != kCreateRelativeLink
|
||||||
&& destIsDir != sourceIsDirectory) {
|
&& destIsDir != sourceIsDirectory) {
|
||||||
// ensure user isn't trying to replace a file with folder or vice versa
|
|
||||||
(new BAlert("", sourceIsDirectory
|
(new BAlert("", sourceIsDirectory
|
||||||
? "You cannot replace a file with a folder or a symbolic link."
|
? "You cannot replace a file with a folder or a symbolic "
|
||||||
: "You cannot replace a folder or a symbolic link with a file.",
|
"link."
|
||||||
"OK", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
|
: "You cannot replace a folder or a symbolic link with a "
|
||||||
|
"file.", "OK", 0, 0, B_WIDTH_AS_USUAL,
|
||||||
|
B_WARNING_ALERT))->Go();
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,9 +1991,10 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
|||||||
char sourceBuffer[96], destBuffer[96];
|
char sourceBuffer[96], destBuffer[96];
|
||||||
StatStruct statBuffer;
|
StatStruct statBuffer;
|
||||||
|
|
||||||
if (!sourceEntry->IsDirectory() && sourceEntry->GetStat(&statBuffer) == B_OK)
|
if (!sourceEntry->IsDirectory() && sourceEntry->GetStat(
|
||||||
|
&statBuffer) == B_OK) {
|
||||||
FileStatToString(&statBuffer, sourceBuffer, 96);
|
FileStatToString(&statBuffer, sourceBuffer, 96);
|
||||||
else
|
} else
|
||||||
sourceBuffer[0] = '\0';
|
sourceBuffer[0] = '\0';
|
||||||
|
|
||||||
if (!entry.IsDirectory() && entry.GetStat(&statBuffer) == B_OK)
|
if (!entry.IsDirectory() && entry.GetStat(&statBuffer) == B_OK)
|
||||||
@ -1949,15 +2002,16 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
|||||||
else
|
else
|
||||||
destBuffer[0] = '\0';
|
destBuffer[0] = '\0';
|
||||||
|
|
||||||
sprintf(replaceMsg, kReplaceStr, name, destBuffer, name, sourceBuffer,
|
sprintf(replaceMsg, kReplaceStr, name, destBuffer, name,
|
||||||
moveMode == kMoveSelectionTo ? "moving" : "copying");
|
sourceBuffer, moveMode == kMoveSelectionTo ? "moving"
|
||||||
|
: "copying");
|
||||||
}
|
}
|
||||||
|
|
||||||
// special case single collision (don't need Replace All shortcut)
|
// special case single collision (don't need Replace All shortcut)
|
||||||
BAlert *alert;
|
BAlert *alert;
|
||||||
if (multipleCollisions || sourceIsDirectory) {
|
if (multipleCollisions || sourceIsDirectory)
|
||||||
alert = new BAlert("", replaceMsg, "Skip", "Replace all");
|
alert = new BAlert("", replaceMsg, "Skip", "Replace all");
|
||||||
} else {
|
else {
|
||||||
alert = new BAlert("", replaceMsg, "Cancel", "Replace");
|
alert = new BAlert("", replaceMsg, "Cancel", "Replace");
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
}
|
}
|
||||||
@ -1996,8 +2050,8 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FSDeleteFolder(BEntry *dir_entry, CopyLoopControl *loopControl, bool update_status,
|
FSDeleteFolder(BEntry *dir_entry, CopyLoopControl *loopControl,
|
||||||
bool delete_top_dir, bool upateFileNameInStatus)
|
bool update_status, bool delete_top_dir, bool upateFileNameInStatus)
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
@ -2021,16 +2075,20 @@ FSDeleteFolder(BEntry *dir_entry, CopyLoopControl *loopControl, bool update_stat
|
|||||||
upateFileNameInStatus);
|
upateFileNameInStatus);
|
||||||
else {
|
else {
|
||||||
err = entry.Remove();
|
err = entry.Remove();
|
||||||
if (update_status)
|
if (update_status) {
|
||||||
loopControl->UpdateStatus(upateFileNameInStatus ? ref.name : "", ref, 1, true);
|
loopControl->UpdateStatus(upateFileNameInStatus ? ref.name
|
||||||
|
: "", ref, 1, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == kTrashCanceled)
|
if (err == kTrashCanceled)
|
||||||
return kTrashCanceled;
|
return kTrashCanceled;
|
||||||
else if (err == B_OK)
|
else if (err == B_OK)
|
||||||
dir.Rewind();
|
dir.Rewind();
|
||||||
else
|
else {
|
||||||
loopControl->FileError(kFileDeleteErrorString, ref.name, err, false);
|
loopControl->FileError(kFileDeleteErrorString, ref.name, err,
|
||||||
|
false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loopControl->CheckUserCanceled())
|
if (loopControl->CheckUserCanceled())
|
||||||
@ -2049,7 +2107,8 @@ FSDeleteFolder(BEntry *dir_entry, CopyLoopControl *loopControl, bool update_stat
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FSMakeOriginalName(BString &string, const BDirectory *destDir, const char *suffix)
|
FSMakeOriginalName(BString &string, const BDirectory *destDir,
|
||||||
|
const char *suffix)
|
||||||
{
|
{
|
||||||
if (!destDir->Contains(string.String()))
|
if (!destDir->Contains(string.String()))
|
||||||
return;
|
return;
|
||||||
@ -2313,7 +2372,8 @@ FSGetBootDeskDir(BDirectory *deskDir)
|
|||||||
BVolumeRoster().GetBootVolume(&bootVol);
|
BVolumeRoster().GetBootVolume(&bootVol);
|
||||||
BPath path;
|
BPath path;
|
||||||
|
|
||||||
status_t result = find_directory(B_DESKTOP_DIRECTORY, &path, true, &bootVol);
|
status_t result = find_directory(B_DESKTOP_DIRECTORY, &path, true,
|
||||||
|
&bootVol);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -2437,7 +2497,8 @@ DirectoryMatches(const BEntry *entry, directory_which which)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DirectoryMatches(const BEntry *entry, const char *additionalPath, directory_which which)
|
DirectoryMatches(const BEntry *entry, const char *additionalPath,
|
||||||
|
directory_which which)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(which, &path, false, NULL) != B_OK)
|
if (find_directory(which, &path, false, NULL) != B_OK)
|
||||||
@ -2455,7 +2516,8 @@ DirectoryMatches(const BEntry *entry, const char *additionalPath, directory_whic
|
|||||||
extern status_t
|
extern status_t
|
||||||
FSFindTrackerSettingsDir(BPath *path, bool autoCreate)
|
FSFindTrackerSettingsDir(BPath *path, bool autoCreate)
|
||||||
{
|
{
|
||||||
status_t result = find_directory (B_USER_SETTINGS_DIRECTORY, path, autoCreate);
|
status_t result = find_directory (B_USER_SETTINGS_DIRECTORY, path,
|
||||||
|
autoCreate);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -2570,8 +2632,8 @@ _DeleteTask(BObjectList<entry_ref> *list, bool confirm)
|
|||||||
|
|
||||||
if (!dontMoveToTrash) {
|
if (!dontMoveToTrash) {
|
||||||
BAlert *alert = new BAlert("", kDeleteConfirmationStr,
|
BAlert *alert = new BAlert("", kDeleteConfirmationStr,
|
||||||
"Cancel", "Move to Trash", "Delete", B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
|
"Cancel", "Move to Trash", "Delete", B_WIDTH_AS_USUAL,
|
||||||
B_WARNING_ALERT);
|
B_OFFSET_SPACING, B_WARNING_ALERT);
|
||||||
|
|
||||||
alert->SetShortcut(0, B_ESCAPE);
|
alert->SetShortcut(0, B_ESCAPE);
|
||||||
alert->SetShortcut(1, 'm');
|
alert->SetShortcut(1, 'm');
|
||||||
@ -2751,7 +2813,7 @@ FSCreateTrashDirs()
|
|||||||
// make trash invisible
|
// make trash invisible
|
||||||
StatStruct sbuf;
|
StatStruct sbuf;
|
||||||
trashDir.GetStat(&sbuf);
|
trashDir.GetStat(&sbuf);
|
||||||
|
|
||||||
PoseInfo poseInfo;
|
PoseInfo poseInfo;
|
||||||
poseInfo.fInvisible = true;
|
poseInfo.fInvisible = true;
|
||||||
poseInfo.fInitedDirectory = sbuf.st_ino;
|
poseInfo.fInitedDirectory = sbuf.st_ino;
|
||||||
@ -2859,17 +2921,21 @@ FSCreateNewFolderIn(const node_ref *dirNode, entry_ref *newRef,
|
|||||||
|
|
||||||
|
|
||||||
ReadAttrResult
|
ReadAttrResult
|
||||||
ReadAttr(const BNode *node, const char *hostAttrName, const char *foreignAttrName,
|
ReadAttr(const BNode *node, const char *hostAttrName,
|
||||||
type_code type, off_t offset, void *buffer, size_t length,
|
const char *foreignAttrName, type_code type, off_t offset, void *buffer,
|
||||||
void (*swapFunc)(void *), bool isForeign)
|
size_t length, void (*swapFunc)(void *), bool isForeign)
|
||||||
{
|
{
|
||||||
if (!isForeign && node->ReadAttr(hostAttrName, type, offset, buffer, length) == (ssize_t)length)
|
if (!isForeign && node->ReadAttr(hostAttrName, type, offset, buffer,
|
||||||
|
length) == (ssize_t)length) {
|
||||||
return kReadAttrNativeOK;
|
return kReadAttrNativeOK;
|
||||||
|
}
|
||||||
|
|
||||||
// PRINT(("trying %s\n", foreignAttrName));
|
// PRINT(("trying %s\n", foreignAttrName));
|
||||||
// try the other endianness
|
// try the other endianness
|
||||||
if (node->ReadAttr(foreignAttrName, type, offset, buffer, length) != (ssize_t)length)
|
if (node->ReadAttr(foreignAttrName, type, offset, buffer, length)
|
||||||
|
!= (ssize_t)length) {
|
||||||
return kReadAttrFailed;
|
return kReadAttrFailed;
|
||||||
|
}
|
||||||
|
|
||||||
// PRINT(("got %s\n", foreignAttrName));
|
// PRINT(("got %s\n", foreignAttrName));
|
||||||
if (!swapFunc)
|
if (!swapFunc)
|
||||||
@ -2883,8 +2949,8 @@ ReadAttr(const BNode *node, const char *hostAttrName, const char *foreignAttrNam
|
|||||||
|
|
||||||
|
|
||||||
ReadAttrResult
|
ReadAttrResult
|
||||||
GetAttrInfo(const BNode *node, const char *hostAttrName, const char *foreignAttrName,
|
GetAttrInfo(const BNode *node, const char *hostAttrName,
|
||||||
type_code *type, size_t *size)
|
const char *foreignAttrName, type_code *type, size_t *size)
|
||||||
{
|
{
|
||||||
attr_info info;
|
attr_info info;
|
||||||
|
|
||||||
@ -2937,9 +3003,11 @@ SniffIfGeneric(const entry_ref *ref)
|
|||||||
BNode node(ref);
|
BNode node(ref);
|
||||||
char type[B_MIME_TYPE_LENGTH];
|
char type[B_MIME_TYPE_LENGTH];
|
||||||
BNodeInfo info(&node);
|
BNodeInfo info(&node);
|
||||||
if (info.GetType(type) == B_OK && strcasecmp(type, B_FILE_MIME_TYPE) != 0)
|
if (info.GetType(type) == B_OK
|
||||||
|
&& strcasecmp(type, B_FILE_MIME_TYPE) != 0) {
|
||||||
// already has a type and it's not octet stream
|
// already has a type and it's not octet stream
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BPath path(ref);
|
BPath path(ref);
|
||||||
if (path.Path()) {
|
if (path.Path()) {
|
||||||
@ -2963,7 +3031,8 @@ SniffIfGeneric(const BMessage *refs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs, bool openWithOK)
|
_TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs,
|
||||||
|
bool openWithOK)
|
||||||
{
|
{
|
||||||
team_id team;
|
team_id team;
|
||||||
|
|
||||||
@ -2990,11 +3059,13 @@ _TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs, bo
|
|||||||
// close possible parent window, if specified
|
// close possible parent window, if specified
|
||||||
const node_ref *nodeToClose = 0;
|
const node_ref *nodeToClose = 0;
|
||||||
int32 numBytes;
|
int32 numBytes;
|
||||||
refs->FindData("nodeRefsToClose", B_RAW_TYPE, (const void **)&nodeToClose, &numBytes);
|
refs->FindData("nodeRefsToClose", B_RAW_TYPE,
|
||||||
|
(const void **)&nodeToClose, &numBytes);
|
||||||
if (nodeToClose)
|
if (nodeToClose)
|
||||||
dynamic_cast<TTracker *>(be_app)->CloseParent(*nodeToClose);
|
dynamic_cast<TTracker *>(be_app)->CloseParent(*nodeToClose);
|
||||||
} else {
|
} else {
|
||||||
alertString << "Could not open \"" << appRef->name << "\" (" << strerror(error) << "). ";
|
alertString << "Could not open \"" << appRef->name << "\" ("
|
||||||
|
<< strerror(error) << "). ";
|
||||||
if (refs && openWithOK && error != B_SHUTTING_DOWN) {
|
if (refs && openWithOK && error != B_SHUTTING_DOWN) {
|
||||||
alertString << kFindAlternativeStr;
|
alertString << kFindAlternativeStr;
|
||||||
BAlert *alert = new BAlert("", alertString.String(),
|
BAlert *alert = new BAlert("", alertString.String(),
|
||||||
@ -3109,7 +3180,8 @@ LoaderErrorDetails(const entry_ref *app, BString &details)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
const char *detail;
|
const char *detail;
|
||||||
for (int32 i = 0; message.FindString(detailName, i, &detail) == B_OK; i++) {
|
for (int32 i = 0; message.FindString(detailName, i, &detail) == B_OK;
|
||||||
|
i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
details += ", ";
|
details += ", ";
|
||||||
details += detail;
|
details += detail;
|
||||||
@ -3146,8 +3218,8 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
alertString << "Could not find an application to open \"" << documentRef.name
|
alertString << "Could not find an application to open \""
|
||||||
<< "\" (" << strerror(error) << "). ";
|
<< documentRef.name << "\" (" << strerror(error) << "). ";
|
||||||
if (openWithOK)
|
if (openWithOK)
|
||||||
alternative = kFindApplicationStr;
|
alternative = kFindApplicationStr;
|
||||||
|
|
||||||
@ -3213,14 +3285,17 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
|
|||||||
mode_t permissions;
|
mode_t permissions;
|
||||||
|
|
||||||
error = entry.GetPermissions(&permissions);
|
error = entry.GetPermissions(&permissions);
|
||||||
if (error == B_OK)
|
if (error == B_OK) {
|
||||||
error = entry.SetPermissions(permissions & ~(S_IXUSR | S_IXGRP | S_IXOTH));
|
error = entry.SetPermissions(permissions
|
||||||
|
& ~(S_IXUSR | S_IXGRP | S_IXOTH));
|
||||||
|
}
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
// we updated the permissions, so let's try again
|
// we updated the permissions, so let's try again
|
||||||
_TrackerLaunchDocuments(NULL, refs, false);
|
_TrackerLaunchDocuments(NULL, refs, false);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
alertString = "Could not update permissions of file \"";
|
alertString = "Could not update permissions of "
|
||||||
|
"file \"";
|
||||||
alertString << app.name << "\". " << strerror(error);
|
alertString << app.name << "\". " << strerror(error);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -3230,7 +3305,8 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
|
|||||||
alternative = kFindApplicationStr;
|
alternative = kFindApplicationStr;
|
||||||
} else if (error == B_LAUNCH_FAILED_APP_IN_TRASH) {
|
} else if (error == B_LAUNCH_FAILED_APP_IN_TRASH) {
|
||||||
alertString << "Could not open \"" << documentRef.name
|
alertString << "Could not open \"" << documentRef.name
|
||||||
<< "\" because application \"" << app.name << "\" is in the Trash. ";
|
<< "\" because application \"" << app.name << "\" is in the "
|
||||||
|
"Trash. ";
|
||||||
alternative = kFindAlternativeStr;
|
alternative = kFindAlternativeStr;
|
||||||
} else if (error == B_LAUNCH_FAILED_APP_NOT_FOUND) {
|
} else if (error == B_LAUNCH_FAILED_APP_NOT_FOUND) {
|
||||||
alertString << "Could not open \"" << documentRef.name << "\" "
|
alertString << "Could not open \"" << documentRef.name << "\" "
|
||||||
@ -3248,11 +3324,13 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
|
|||||||
alertString << "Could not open \"" << documentRef.name << "\" ";
|
alertString << "Could not open \"" << documentRef.name << "\" ";
|
||||||
if (openedDocuments)
|
if (openedDocuments)
|
||||||
alertString << "with application \"" << app.name << "\" ";
|
alertString << "with application \"" << app.name << "\" ";
|
||||||
alertString << "(Missing libraries: " << loaderErrorString << "). \n";
|
alertString << "(Missing libraries: " << loaderErrorString
|
||||||
|
<< "). \n";
|
||||||
alternative = kFindAlternativeStr;
|
alternative = kFindAlternativeStr;
|
||||||
} else {
|
} else {
|
||||||
alertString << "Could not open \"" << documentRef.name
|
alertString << "Could not open \"" << documentRef.name
|
||||||
<< "\" with application \"" << app.name << "\" (" << strerror(error) << "). ";
|
<< "\" with application \"" << app.name << "\" ("
|
||||||
|
<< strerror(error) << "). ";
|
||||||
alternative = kFindAlternativeStr;
|
alternative = kFindAlternativeStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3280,12 +3358,15 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
|
|||||||
// should fix that, making them void
|
// should fix that, making them void
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
TrackerLaunch(const entry_ref *appRef, const BMessage *refs, bool async, bool openWithOK)
|
TrackerLaunch(const entry_ref *appRef, const BMessage *refs, bool async,
|
||||||
|
bool openWithOK)
|
||||||
{
|
{
|
||||||
if (!async)
|
if (!async)
|
||||||
_TrackerLaunchAppWithDocuments(appRef, refs, openWithOK);
|
_TrackerLaunchAppWithDocuments(appRef, refs, openWithOK);
|
||||||
else
|
else {
|
||||||
AsynchLaunchBinder(&_TrackerLaunchAppWithDocuments, appRef, refs, openWithOK);
|
AsynchLaunchBinder(&_TrackerLaunchAppWithDocuments, appRef, refs,
|
||||||
|
openWithOK);
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@ -3532,7 +3613,8 @@ WellKnowEntryList::AddOne(directory_which which, directory_which base,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WellKnowEntryList::AddOne(directory_which which, const char *path, const char *name)
|
WellKnowEntryList::AddOne(directory_which which, const char *path,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
BEntry entry(path, true);
|
BEntry entry(path, true);
|
||||||
node_ref node;
|
node_ref node;
|
||||||
@ -3560,32 +3642,35 @@ WellKnowEntryList::WellKnowEntryList()
|
|||||||
|
|
||||||
AddOne(B_BEOS_APPS_DIRECTORY, "apps");
|
AddOne(B_BEOS_APPS_DIRECTORY, "apps");
|
||||||
AddOne(B_APPS_DIRECTORY, "apps");
|
AddOne(B_APPS_DIRECTORY, "apps");
|
||||||
AddOne((directory_which)B_USER_DESKBAR_APPS_DIRECTORY, B_USER_DESKBAR_DIRECTORY,
|
AddOne((directory_which)B_USER_DESKBAR_APPS_DIRECTORY,
|
||||||
"Applications", "apps");
|
B_USER_DESKBAR_DIRECTORY, "Applications", "apps");
|
||||||
|
|
||||||
AddOne(B_BEOS_PREFERENCES_DIRECTORY, "preferences");
|
AddOne(B_BEOS_PREFERENCES_DIRECTORY, "preferences");
|
||||||
AddOne(B_PREFERENCES_DIRECTORY, "preferences");
|
AddOne(B_PREFERENCES_DIRECTORY, "preferences");
|
||||||
AddOne((directory_which)B_USER_DESKBAR_PREFERENCES_DIRECTORY, B_USER_DESKBAR_DIRECTORY,
|
AddOne((directory_which)B_USER_DESKBAR_PREFERENCES_DIRECTORY,
|
||||||
"Preferences", "preferences");
|
B_USER_DESKBAR_DIRECTORY, "Preferences", "preferences");
|
||||||
|
|
||||||
AddOne((directory_which)B_USER_MAIL_DIRECTORY, B_USER_DIRECTORY, "mail", "mail");
|
AddOne((directory_which)B_USER_MAIL_DIRECTORY, B_USER_DIRECTORY, "mail",
|
||||||
|
"mail");
|
||||||
|
|
||||||
AddOne((directory_which)B_USER_QUERIES_DIRECTORY, B_USER_DIRECTORY, "queries", "queries");
|
AddOne((directory_which)B_USER_QUERIES_DIRECTORY, B_USER_DIRECTORY,
|
||||||
|
"queries", "queries");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AddOne(B_COMMON_DEVELOP_DIRECTORY, "develop");
|
AddOne(B_COMMON_DEVELOP_DIRECTORY, "develop");
|
||||||
AddOne((directory_which)B_USER_DESKBAR_DEVELOP_DIRECTORY, B_USER_DESKBAR_DIRECTORY,
|
AddOne((directory_which)B_USER_DESKBAR_DEVELOP_DIRECTORY,
|
||||||
"Development", "develop");
|
B_USER_DESKBAR_DIRECTORY, "Development", "develop");
|
||||||
|
|
||||||
AddOne(B_USER_CONFIG_DIRECTORY, "config");
|
AddOne(B_USER_CONFIG_DIRECTORY, "config");
|
||||||
|
|
||||||
AddOne((directory_which)B_USER_PEOPLE_DIRECTORY, B_USER_DIRECTORY, "people", "people");
|
AddOne((directory_which)B_USER_PEOPLE_DIRECTORY, B_USER_DIRECTORY,
|
||||||
|
"people", "people");
|
||||||
|
|
||||||
AddOne((directory_which)B_USER_DOWNLOADS_DIRECTORY, B_USER_DIRECTORY, "downloads",
|
AddOne((directory_which)B_USER_DOWNLOADS_DIRECTORY, B_USER_DIRECTORY,
|
||||||
"downloads");
|
"downloads", "downloads");
|
||||||
}
|
}
|
||||||
|
|
||||||
WellKnowEntryList *WellKnowEntryList::self = NULL;
|
WellKnowEntryList *WellKnowEntryList::self = NULL;
|
||||||
|
|
||||||
}
|
} // namespace BPrivate
|
||||||
|
Loading…
Reference in New Issue
Block a user