Folderitem's CopyFileTo is (still) buggy for files with long file names.
CopyFileto method creates a copy, which has invalid folderitem
properties (name, absolutePath) and therefore can't be accessed with
calls like OpenAsBinary().
This problem popped up in Tiger 10.4.2 and is also present in RB 2005,
running IDE and compiled apps. Maybe someone can check if this problem
also appears using Tiger 10.4.0 - 10.4.1?
Workaround:
After copying the file using copyfileto, set the name property of the
destination file to the original value.
Steps to Reproduce:
Make a new project with one windows and one button.
Set buttons action event handler to:
DIM theFName1, theFName2 as String
DIM theSourceFolderItem, theDestFolderItem as FolderItem
DIM theBS as BinaryStream
theFName1 = "this is a really a not so long file name1"
theFName2 = "this is a really a not so long file name2"
theSourceFolderItem = DesktopFolder.Child (theFName1)
theDestFolderItem = DesktopFolder.Child (theFName2)
//make sure those files don't exist
theSourceFolderItem.delete
theDestFolderItem.delete
//create the file to be copied
theBS = theSourceFolderItem.CreateBinaryFile("")
theBS.close
// test: open the source file (long file name)
theBS = theSourceFolderItem.OpenAsBinaryFile(true)
theBS.close
// copy source file
theSourceFolderItem.CopyFileTo theDestFolderItem
// my workaround: reassign the folderitem's name property (uncomment
next line!)
// theDestFolderItem.name = theFName2
// test: open the copy (long file name)
theBS = theDestFolderItem.OpenAsBinaryFile(true)
if (theBS = nil) then
msgbox "PROBLEM: theDestFolderItem = Nil" + EndofLine + EndOFLine +
"The destination file could not be opened as a binary file"
else
theBS.close
end if
The bug report:
http://www.realsoftware.com/feedback/viewreport.php?reportid=fjyqngvk
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|