LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   mkdir (https://www.linuxquestions.org/questions/programming-9/mkdir-917488/)

shamjs 12-06-2011 10:42 PM

mkdir
 
Hi all,
im not able to create a directory by using mkdir API

here is my sample debugged information.
Code:

213            string userTemp = std::getenv("HOME");
(gdb)
214            userTemp += "/";
(gdb) p userTemp
$4 = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0x83a0514 "/home/shamjs"}}
(gdb) n
216            if( userTemp.find_last_of("/\\") != (userTemp.size()-1) )
(gdb)
220            userTemp = userTemp + ".OlupX/";
(gdb)
224            int ret = mkdir(userTemp.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
(gdb) p userTemp
$5 = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0x83a079c "/home/shamjs/.OlupX/"}}
(gdb) n
227            if( stempfolder.empty() )
(gdb) p ret
$6 = -1
(gdb) n
230                    stempfolder = userTemp + stempfolder + stream.str();

i dont have any folder by name .OlupX in my home directory

plz suggest me ...

waiting for your reply........


EricTRA 12-06-2011 11:39 PM

Hello,

You marked your thread as solved. Would you please share what you've found out so that others in a similar situation can see if it works for them? Thanks in advance.

Kind regards,

Eric

shamjs 12-06-2011 11:48 PM

Sure Eric,

i handled the mkdir error message by
Code:

if(ret==-1)
        {
        printf("error while creating mkdr %s\n",strerror(errno));
        }

then i got error msg as File Exists

since it was an hiden file hence by using ls it has not displayed ,so by using ls -a problem was fixed

EricTRA 12-07-2011 12:15 AM

Hi,

Thank you very much for sharing. Enjoy Linux.

Kind regards,

Eric


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