Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Add fs.makedir() and fs.rename() APIs #120

Merged
merged 6 commits into from
Oct 3, 2012
Merged

Conversation

gruehle
Copy link
Member

@gruehle gruehle commented Sep 26, 2012

Add two new functions to brackets.fs:

makedir()

/**
 * Create a new directory.
 *
 * @param {string} path The path of the directory to create.
 * @param {number} mode The permissions for the directory, in numeric format (ie 0777)
 * @param {function(err)} callback Asynchronous callback function. The callback gets one argument.
 *
 * @return None. This is an asynchronous call that sends all return information to the callback.
 **/
function makedir(path, mode, callback);

NOTE
The mode parameter of makedir() is ignored for now. The directory is created with the full
permissions available to the current user.

rename()

/**
 * Rename a file or directory.
 *
 * @param {string} oldPath The old name of the file or directory.
 * @param {string} newPath The new name of the file or directory.
 * @param {function(err)} callback Asynchronous callback function. The callback gets one argument.
 *
 * @return None. This is an asynchronous call that sends all return information to the callback.
 **/
function rename(oldPath, newPath, callback);

BONUS FEATURES
This pull request also includes two small bonus features on the mac:

  • The main window size and position is now remembered when quitting and relaunching Brackets. This change will also fix the issues on the Mac where some of the UI is not shown if the initial window size is too small (Display error on MacBook Pro (13") brackets#1689)
  • The file dialogs are now modal sheets instead of modal dialogs.

@redmunds
Copy link
Contributor

redmunds commented Oct 1, 2012

I am getting a build error on Mac OS X v10.6 due to the NSFileWriteFileExistsError flag is only available on OS X v10.7 and later.

@gruehle
Copy link
Member Author

gruehle commented Oct 2, 2012

Thanks for reviewing!

Are you using XCode 4.x? XCode 3.2.6 is no longer supported.

I don't have a 10.6 system with me for testing, but this should be fine when running on a 10.6 system. If you try to rename an item to a name of an existing item, you will get a less friendly error message, but everything should work fine.

@jasonsanjose
Copy link
Member

I'll take on the mac side of the review.

@ghost ghost assigned jasonsanjose Oct 2, 2012
@redmunds
Copy link
Contributor

redmunds commented Oct 2, 2012

Windows looks good. Re-assigning to @jasonsanjose to take a look at Mac (since I need to upgrade to Xcode 4).

NSString* pathStr = [NSString stringWithUTF8String:path.c_str()];

// TODO: honor mode
[[NSFileManager defaultManager] createDirectoryAtPath:pathStr withIntermediateDirectories:FALSE attributes:nil error:&error];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonsanjose
Copy link
Member

Looks good. Merging

jasonsanjose added a commit that referenced this pull request Oct 3, 2012
Add fs.makedir() and fs.rename() APIs
@jasonsanjose jasonsanjose merged commit 5f4cf3c into master Oct 3, 2012
DennisKehrig added a commit to DennisKehrig/brackets-shell that referenced this pull request Oct 8, 2012
Makes sure that the default size definitely fits the available space. It will only be used on the first launch of Brackets.
Subsequent launches use stored window size and position which is adjusted automatically by the OS.
@DennisKehrig DennisKehrig mentioned this pull request Oct 8, 2012
jasonsanjose added a commit that referenced this pull request Dec 8, 2015
Add fs.makedir() and fs.rename() APIs
DennisKehrig added a commit that referenced this pull request Dec 8, 2015
Makes sure that the default size definitely fits the available space. It will only be used on the first launch of Brackets.
Subsequent launches use stored window size and position which is adjusted automatically by the OS.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants