Thread: Basic folder creation

  1. #1
    Registered User
    Join Date
    Apr 2016
    Posts
    3

    Basic folder creation

    Hello folks. Just now learning to program. I writing a basic program that with a text input and button click will create a top-level folder (named with text input) and series of subfolders, and sub-subfolders in a directory. (each named appropriately.) Forgive me if this is a dumb question.

    Would it be better to use the script in the code to just create new set of folders with the correct naming scheme, or would it better better to just "copy" the folders over from a master directory and then just renaming the top level folder? Or some other method or combination of the two?

    My thought is that if you have a "master directory" you could easily add sub folders to be copied without accessing the source code. This master directory would only then be accessible to the appropriate personnel.


    Thanks for your input

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Every platform has its own set of APIs to create and manipulate files and folders. What operating system are you developing for?

    If you want it to work on all platforms, you might consider a framework, such as boost or Poco
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Apr 2016
    Posts
    3
    Windows 10. This is just proof of concept that i can show to someone else for a full build out. So I'm just trying to do it as basic and wasily as possible

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Elkvis View Post
    Every platform has its own set of APIs to create and manipulate files and folders. What operating system are you developing for?

    If you want it to work on all platforms, you might consider a framework, such as boost or Poco
    C++ has it too in form of the Filesystem TS.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Elysia View Post
    C++ has it too in form of the Filesystem TS.
    That's true, but not all compilers have an implementation of it yet, so I tend to steer people toward solutions that will work today, rather than those that will work someday.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, each to their own. But I did want to make it known out there.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Apr 2016
    Posts
    3
    I have absolutely no idea how to implement this... and for the love of god no one in houston has programming classes without a bunch of hassle and nothing at night.. -_- back to my book....

  8. #8
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Elysia View Post
    C++ has it too in form of the Filesystem TS.
    Yeah, I don't trust anything in C++17 to actually come out. If anything, I think they might just repackage C++14 as 17 and call it a day.

  9. #9
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    It looks to me like the experimental file system TS is available with C++14.

    Jim

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MutantJohn View Post
    Yeah, I don't trust anything in C++17 to actually come out. If anything, I think they might just repackage C++14 as 17 and call it a day.
    Highly unlikely. Are you just saying that or tracking the standard? Because that's just nonsense.
    A lot of things have been voted into the standard and there are already lots of implementations available.

    As for the OP, here's an example of how to use Boost.
    Now, here's specifically how to create a directory.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Good news is that bash scripting may soon be practical for such work on multiple OS's. And just when I master batch too.....

    gg

  12. #12
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Code:
    bool create_directory(const char* pn)
    {
            #ifdef _WIN32
            return CreateDirectoryA(pn, NULL);
            #endif
            #ifdef __unix__
            return mkdir(pn, 0775);
            #endif
    }
    You're welcome

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic file creation and appending.. ofstream vs. WriteFile
    By rodrigorules in forum Windows Programming
    Replies: 2
    Last Post: 07-07-2010, 06:51 PM
  2. Replies: 2
    Last Post: 12-16-2008, 02:43 PM
  3. Basic Window Creation, Dev C++ 4.9.9.0 Linking Error
    By Tronic in forum Windows Programming
    Replies: 2
    Last Post: 11-27-2004, 06:03 PM
  4. deleting a folder AND copying a folder
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 05-01-2004, 08:48 AM
  5. Game creation tutorials for visual basic
    By S. Omnipotence in forum Game Programming
    Replies: 4
    Last Post: 01-15-2002, 10:44 PM