Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 28, 2011, 04:07 AM   #1
ccjimmy
macrumors newbie
 
Join Date: Mar 2011
mkdir problems on create folders on MAC

currently I use the function mkdir(const char* name,mode_t) to create a file-forder on MAC OS, it can create the folder in success. but When I double click the folder been created before to open it, MAC OS will prompt a messagebox which says I have no enough permission to see its content.
I've tried several times with the mode_t is 777,666,ect. the same result appears.

the path I want to create is /Users/$current_user/Document

any idea?
ccjimmy is offline   0 Reply With Quote
Old Apr 28, 2011, 04:21 AM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
This code works for me:
Code:
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>

int main (int argc, const char * argv[])
{
    int r = mkdir("/Users/jim/NewFolder", 0777);
    if (r == 0) {
        printf("Success\n");
        return EXIT_SUCCESS;
    } else {
        printf("Failed\n");
        perror("Failed");
        return EXIT_FAILURE;
    }
}
I've just wondered if you've remembered to put the initial 0 in the mode so it's an octal constant and not an integer constant.

Assuming you're actually trying to create a Documents directory, why are you trying to do this? Every home directory (unless the user has gone to a lot of effort) will already have a Documents directory.
jiminaus is offline   0 Reply With Quote
Old Apr 28, 2011, 05:08 AM   #3
ccjimmy
Thread Starter
macrumors newbie
 
Join Date: Mar 2011
Quote:
Originally Posted by jiminaus View Post
This code works for me:
Code:
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>

int main (int argc, const char * argv[])
{
    int r = mkdir("/Users/jim/NewFolder", 0777);
    if (r == 0) {
        printf("Success\n");
        return EXIT_SUCCESS;
    } else {
        printf("Failed\n");
        perror("Failed");
        return EXIT_FAILURE;
    }
}
I've just wondered if you've remembered to put the initial 0 in the mode so it's an octal constant and not an integer constant.

Assuming you're actually trying to create a Documents directory, why are you trying to do this? Every home directory (unless the user has gone to a lot of effort) will already have a Documents directory.



thanks, I lost the initial 0 in the mode............
thank you,friend!
ccjimmy is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
6 Displays on Mac Pro 1.1 w/ Dual Radeon 5770 Ibrin Mac Pro 13 Feb 28, 2014 03:28 AM
Problem Creating Mail on Mac Client unclenice OS X 0 Jun 7, 2011 10:47 AM
Problem with accessing a Windows network shared folder on MAC buh OS X 0 Nov 7, 2008 03:10 PM
can you create folders on the Iphone 'home' screen? vivithemage iPhone 6 Jul 28, 2008 07:10 PM


All times are GMT -5. The time now is 09:00 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC