Быстрый перенос файлов на носителе

Clarion, Clarion 7

Модератор: Дед Пахом

Правила форума
При написании вопроса или обсуждении проблемы, не забывайте указывать версию Clarion который Вы используете.
А так же пользуйтесь спец. тегами при вставке исходников!!!
Ответить
Гость

Сообщение Гость »

А вот с такой задачей случайно никто не сталкивался?
Для переноса файлов из одной папки в другую (на одном и том же носителе) в Кларионе иметься операторы:
Copy() и Remove()
До сегодняшнего дня я ими пользовался и голова не болела. Но вот когда начал переносить файлы в пределах съемного устройства (Flash), тогда-то и столкнулся с ужасными тормозами. Оказывается, сначала файл физически копируется в новую папку на том же носителе, а затем удаляется исходник.
Вопрос в том, как можно просто переписать информацию в FATе, не дергая сам файл (как, например в Fare по F6)? Средствами Клариона, разумеется.
Даже самому интересно.:)
Написал: NewUser(217)
Аватара пользователя
Admin
Администратор
Сообщения: 3960
Зарегистрирован: 05 Июль 2005, 15:59
Откуда: Хабаровск
Благодарил (а): 25 раз
Поблагодарили: 22 раза
Контактная информация:

Сообщение Admin »

The MoveFileEx function renames an existing file or directory.

BOOL MoveFileEx(

LPCTSTR lpExistingFileName, // address of name of the existing file
LPCTSTR lpNewFileName, // address of new name for the file
DWORD dwFlags // flag to determine how to move file
);


Parameters

lpExistingFileName

Points to a null-terminated string that names an existing file or directory.

lpNewFileName

Points to a null-terminated string that specifies the new name of lpExistingFileName.
When moving a file, the destination can be on a different file system or drive. If the destination is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags.
When moving a directory, the destination must be on the same drive.

Windows NT:

If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT, lpNewFileName can be NULL. In this case, MoveFileEx registers the lpExistingFileName file to be deleted when the system reboots.

dwFlags

A set of bit flags that specify how to move the file. You can specify any combination of the following values:

Value Meaning
MOVEFILE_COPY_ALLOWED
If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions. Cannot be combined with the MOVEFILE_DELAY_UNTIL_REBOOT flag.
MOVEFILE_DELAY_UNTIL_REBOOT
Windows NT only: The function does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups.
MOVEFILE_REPLACE_EXISTING
If a file of the name specified by lpNewFileName already exists, the function replaces its contents with those specified by lpExistingFileName.
MOVEFILE_WRITE_THROUGH
Windows NT only: The function does not return until the file has actually been moved on the disk. Setting this flag guarantees that a move perfomed as a copy and delete operation is flushed to disk before the function returns. The flush occurs at the end of the copy operation. This flag has no effect if the MOVEFILE_DELAY_UNTIL_REBOOT flag is set.


Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

An application cannot specify both MOVEFILE_DELAY_UNTIL_REBOOT and MOVEFILE_COPY_ALLOWED for dwFlags. Function calls that do so will fail.

Windows NT:

If the dwFlags parameter specifies MOVEFILE_DELAY_UNTIL_REBOOT, MoveFileEx stores the locations of the files to be renamed at reboot under the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
Control\Session Manager\PendingFileRenameOperations

The key is of type REG_MULTI_SZ. Each rename operation is a pair of NULL-terminated strings. The system uses these registry entries to complete the operation at reboot in the same order that they were issued.
For example, on Windows NT, the following code fragment creates registry entries that delete szDstFile and rename szSrcFile to be szDstFile at reboot:



MoveFileEx(szDstFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);


The system creates the associated PendingFileRenameOperations entries as follows:

szDstFile\0\0
szSrcFile\0szDstFile\0\0


Windows 95:

The MOVEFILE_DELAY_UNTIL_REBOOT flag is not supported. To rename or delete a file at reboot on a Windows 95 system, place an entry in the WININIT.INI file in the Windows directory.

For example, on Windows 95, the following code fragment creates WININIT.INI entries that delete szDstFile and rename szSrcFile to be szDstFile at reboot:

GetWindowsDirectory(szWinInitFile, uSize);
lstrcat(szWinInitFile, "\\WININIT.INI");
WritePrivateProfileString("Rename", "NUL", szDstFile, szWinInitFile);
WritePrivateProfileString("Rename", szDstFile, szSrcFile, szWinInitFile);

Написал: Mixer(144)
Аватара пользователя
Admin
Администратор
Сообщения: 3960
Зарегистрирован: 05 Июль 2005, 15:59
Откуда: Хабаровск
Благодарил (а): 25 раз
Поблагодарили: 22 раза
Контактная информация:

Сообщение Admin »

В общем ответ простой - используй Window API
Написал: Mixer(144)
Гость

Сообщение Гость »

Спасибо, Mixer, за помощь. Буду разбираться. Т.к. опыта работы с API практически нет никакого, то, по всей видимости, прийдеться мне не раз еще прибегать к помощи знатаков.
Написал: NewUser(217)
Гость

Сообщение Гость »

Как ни странно, но все получилось с пол-пинка! Огромное спасибо!
Только вот с MoveFileExA не совсем разобрался…. 
Прототип: MoveFileExA(*LPCSTR,*LPCSTR,DWORD),BOOL,PASCAL,RAW
Где DWORD может принимать следующие значения:
MOVEFILE_COPY_ALLOWED
MOVEFILE_DELAY_UNTIL_REBOOT flag.
MOVEFILE_DELAY_UNTIL_REBOOT

MoveFileExA(loc:OldPath,loc:NewPath,2), например – выдает ошибку при исполнении.
Вопрос: какие значения должен принимать этот третий параметр?
Написал: NewUser(217)
Аватара пользователя
Admin
Администратор
Сообщения: 3960
Зарегистрирован: 05 Июль 2005, 15:59
Откуда: Хабаровск
Благодарил (а): 25 раз
Поблагодарили: 22 раза
Контактная информация:

Сообщение Admin »

Попробуй прототип попроще...
MoveFile (*CSTRING,*CSTRING),BYTE,PASCAL,RAW,PROC,NAME('MoveFileA')
это должно прокатить без проблем
------------------------
The MoveFile function renames an existing file or a directory (including all its children).

BOOL MoveFile(

LPCTSTR lpExistingFileName, // address of name of the existing file
LPCTSTR lpNewFileName // address of new name for the file
);


Parameters

lpExistingFileName

Points to a null-terminated string that names an existing file or directory.

lpNewFileName

Points to a null-terminated string that specifies the new name of a file or directory. The new name must not already exist. A new file may be on a different file system or drive. A new directory must be on the same drive.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The MoveFile function will move (rename) either a file or a directory (including all its children) either in the same directory or across directories. The one caveat is that the MoveFile function will fail on directory moves when the destination is on a different volume.
Написал: Mixer(144)
Ответить