How do I specify a directory with ifstream and ofstream?

This is a discussion on How do I specify a directory with ifstream and ofstream? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by laserlight Yes, but not with the standard library. You could consider the use of Boost.Filesystem . Where ...

  1. #16
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by laserlight View Post
    Yes, but not with the standard library. You could consider the use of Boost.Filesystem.
    Where do I download this library?

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    It's part of the boost library available at the same site that hosts that doc page.

  3. #18
    Programming Ninja In-T...
    Join Date
    May 2009
    Posts
    827
    Quote Originally Posted by Daved View Post
    It's part of the boost library available at the same site that hosts that doc page.
    Ahh...ok. Thanks. I guess I was expecting to see a link to download it at the part of the site I was viewing.

  4. #19
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Streams are designed for what their name implies - streams. Just b/c it is a file stream does not mean it can navigate folder structures. That is normally up to the operating system. The C standard library as well as the Win32 API provide plenty of functionality for all of that.

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,976
    Quote Originally Posted by Bubba
    Streams are designed for what their name implies - streams. Just b/c it is a file stream does not mean it can navigate folder structures. That is normally up to the operating system.
    If by "navigate folder structures" you mean access files that are outside the current directory, then I believe that it can, but the path name format is implementation defined, which in this case means operating system dependent. This is why I suggested the use of Boost.Filesystem as it provides a generally portable solution.

    Quote Originally Posted by Bubba
    The C standard library as well as the Win32 API provide plenty of functionality for all of that.
    I do not think that the C standard library has any advantage over the C++ I/O streams in this respect. The respective functions are also concerned about file names, not directory names or path names in general.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #21
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Yes but you have such things as setcwd and getcwd and so forth that do interact with the file system. Just b/c you can specify a path for ifstream and ofstream does not mean they should be used for folder navigation.

  7. #22
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,976
    Quote Originally Posted by Bubba
    Yes but you have such things as setcwd and getcwd and so forth that do interact with the file system.
    setcwd and getcwd are not part of the C standard library.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ofstream... broke as a result of ifstream fix
    By tms43 in forum C++ Programming
    Replies: 3
    Last Post: 11-12-2006, 10:40 AM
  2. ofstream and ifstream for searching and writing
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-17-2003, 07:34 AM
  3. ofstream, ifstream?
    By Kavity in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2003, 08:49 PM
  4. Replies: 9
    Last Post: 06-06-2002, 07:03 PM
  5. STL to: Cin, Cout, ifstream & ofstream
    By kuphryn in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2001, 08:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21