Bug 130556 - Extra isDirectory call in LocalFile.mkdir
Summary: Extra isDirectory call in LocalFile.mkdir
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.1.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2006-03-06 10:05 EST by John Arthorne CLA
Modified: 2006-03-06 10:10 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2006-03-06 10:05:00 EST
LocalFile.mkdir has this code:


file.mkdir();
if (!file.isDirectory())
  throw new Exception(...)

Investigate whether this isDirectory check is necessary, rather than just checking the return value of mkdir().
Comment 1 John Arthorne CLA 2006-03-06 10:10:14 EST
I remember the answer to this.  mkdir() returns true only if it created the directory.  So, if the directory already existed before the call, it returns false.  So, to eliminate the isDirectory() call, we would have to do an exists() call instead, with the same cost.

if (!file.exists()) {
  if (!file.mkdir())
     throw new Exception(....)