Re: Needed information regarding solving File Renaming Bug



Hi Pranav

On 2016-03-01 01:40, Pranav Ganorkar <pranavg189 gmail com> wrote:
ET_File_Name_Check_Length(ETFile,new_file_name)

I understood that we can use the stat() function defined in sys/stat.h to
get the info about the file name length and then check for ENAMETOOLONG
errno returned by this function. But after we detect this error, I want to
ask what could be an appropriate way of handling this error ? should we
just return failure in the functions using the ET_File_Name_Check_Length()
function.

If you look at the old implementation of ET_File_Name_Check_Length(), you will see that the filename length check depends on the file type (as for some files, a temporary file is created, for which an extra 6 characters are required). You would not use stat() in this case because there's a GIO API that you would use instead, and also the filename is already passed directly, so there is no need to query the on-disk file.

You need to think about whether to check the length of the filename in advance of any rename operation (which is the approach taken with the ET_File_Name_Check_Length()), or whether to handle the name-too-long error from each rename.

You need to think carefully about what the appropriate course of action to take in each situation might be, such as shortening the filename, prompting the user for a different filename and so on.

Also, I am not understanding why we are passing ETFile struct to the
ET_File_Name_Check_Length() function. we are just supposed to check the
length of filename right. so , we just need to pass the new file name that
will be entered by the user.

As the length of filename may be different depending on the file type, the ET_File struct is passed along too.

--
http://amigadave.com/

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]