[haiku-bugs] Re: [Haiku] #10928: [Screenshot] Artwork folder is read-only (easy)

  • From: "gbl08ma" <trac@xxxxxxxxxxxx>
  • Date: Tue, 06 Sep 2016 20:45:06 -0000

#10928: [Screenshot] Artwork folder is read-only (easy)
---------------------------------------+----------------------------
   Reporter:  diver                    |      Owner:  nobody
       Type:  bug                      |     Status:  reopened
   Priority:  normal                   |  Milestone:  R1
  Component:  Applications/Screenshot  |    Version:  R1/Development
 Resolution:                           |   Keywords:
 Blocked By:                           |   Blocking:
Has a Patch:  1                        |   Platform:  All
---------------------------------------+----------------------------

Comment (by gbl08ma):

 Replying to [comment:6 pulkomandy]:

Hi,
The patch looks good. But there are possible improvements:

1) From the coding guidelines:
{{{
Variables start with lowercase letters and use interCapsFormatting.
}}}

 Oops, I saw this guideline and yet managed to break it.

2) Testing that the directory exists is not enough. It could be a file
 or a broken symlink, and in these cases the code below will fail anyway.
 You could use BEntry.IsDirectory() instead.

 I read the docs on api.haiku-os.org and I'm still a bit confused over what
 BDirectory, BEntry, BFile and BPath do, and managed to miss IsDirectory
 because it comes from BStatable (which in hindsight makes perfect sense, I
 should have clicked to see the list of all members).

3) Creating a temporary BDirectory just for calling CreateDirectory with
 an absolute path is not very useful. You could use the C function
 create_directory instead.

 This came from an attempt to stick to object-oriented APIs, and because I
 couldn't find docs pointing me to create_directory. I looked for a static
 method in BDirectory to do this (since I agree it doesn't make any sense
 to create a BDirectory for this) but forgot to look for methods outside of
 the class. I'm still new to the Haiku API organization style, so forgive
 me :)

 I'll redo my patch (eventually after some minor git wrestling) and
 reupload.

--
Ticket URL: <https://dev.haiku-os.org/ticket/10928#comment:7>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: