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

Merged
merged 6 commits into from Oct 3, 2012

Projects

None yet

3 participants

@gruehle
Member
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 (adobe/brackets#1689)
  • The file dialogs are now modal sheets instead of modal dialogs.
@gruehle gruehle referenced this pull request in adobe/brackets Sep 26, 2012
Merged

Add "New Folder" and "Rename" features #1719

@redmunds redmunds was assigned Oct 1, 2012
@redmunds
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
Member
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
Member

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

@jasonsanjose jasonsanjose was assigned Oct 2, 2012
@redmunds
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).

@jasonsanjose jasonsanjose commented on an outdated diff Oct 3, 2012
appshell/appshell_extensions_mac.mm
@@ -337,6 +339,28 @@ int32 ReadDir(ExtensionString path, CefRefPtr<CefListValue>& directoryContents)
return ConvertNSErrorCode(error, true);
}
+int32 MakeDir(ExtensionString path, int32 mode)
+{
+ NSError* error = nil;
+ NSString* pathStr = [NSString stringWithUTF8String:path.c_str()];
+
+ // TODO: honor mode
+ [[NSFileManager defaultManager] createDirectoryAtPath:pathStr withIntermediateDirectories:FALSE attributes:nil error:&error];
@jasonsanjose jasonsanjose commented on an outdated diff Oct 3, 2012
appshell/appshell_extensions_win.cpp
@@ -554,6 +554,22 @@ int32 ReadDir(ExtensionString path, CefRefPtr<CefListValue>& directoryContents)
return NO_ERROR;
}
+int32 MakeDir(ExtensionString path, int32 mode)
+{
+ if (!CreateDirectory(path.c_str(), NULL))
@jasonsanjose
Member

Looks good. Merging

@jasonsanjose jasonsanjose merged commit 5f4cf3c into master Oct 3, 2012
@DennisKehrig DennisKehrig added a commit to DennisKehrig/brackets-shell that referenced this pull request Oct 8, 2012
@DennisKehrig DennisKehrig Modified fix for adobe/brackets#1147 based on Glenn's work in #120
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.
bc3cc66
@DennisKehrig DennisKehrig referenced this pull request Oct 8, 2012
Merged

Substitute for #124 #125

@DennisKehrig DennisKehrig added a commit that referenced this pull request Dec 8, 2015
@DennisKehrig DennisKehrig Modified fix for adobe/brackets#1147 based on Glenn's work in #120
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.
f4d580d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment