Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++ and directories

Reply
Thread Tools

C++ and directories

 
 
Edward Hvarregaard
Guest
Posts: n/a
 
      08-16-2011
newby here

I am having trouble getting started in C++ I have done some programming in
PASCAL where I had no problem finding the commands needed to deal with
directories, files and attributes. where can I find the similar commands
for C++ ?

The startup code I need must do the following

If "C:\SSF\ProgramFiles\Exch.txt" does not exist
then Setup

Setup needs to be a function that creates missing path elements and an
empty "Exch.txt" file

Thanks

Ed

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      08-16-2011
On 08/16/11 12:49 PM, Edward Hvarregaard wrote:
> newby here
>
> I am having trouble getting started in C++ I have done some programming in
> PASCAL where I had no problem finding the commands needed to deal with
> directories, files and attributes. where can I find the similar commands
> for C++ ?
>
> The startup code I need must do the following
>
> If "C:\SSF\ProgramFiles\Exch.txt" does not exist
> then Setup
>
> Setup needs to be a function that creates missing path elements and an
> empty "Exch.txt" file


If boost filesystem doesn't meet your needs, use the C filesystem
interface provided by your platform.

--
Ian Collins
 
Reply With Quote
 
 
 
 
Nobody
Guest
Posts: n/a
 
      08-16-2011
On Mon, 15 Aug 2011 17:49:55 -0700, Edward Hvarregaard wrote:

> I am having trouble getting started in C++ I have done some programming
> in PASCAL where I had no problem finding the commands needed to deal with
> directories, files and attributes. where can I find the similar commands
> for C++ ?


The C++ language isn't tied to a specific platform. Consequently, it
doesn't include features which are platform-specific. Directories are such
a feature: not all platforms have them, and those that do can have wildly
different semantics.

So you need to use either a third-party library (e.g. boost::filesystem),
or the platform's native OS functions (e.g. opendir/readdir/closedir on
Unix, FindFirstFile/FindNextFile/FindClose on Windows).

 
Reply With Quote
 
Jens Thoms Toerring
Guest
Posts: n/a
 
      08-16-2011
Ian Collins <ian-> wrote:
> On 08/16/11 12:49 PM, Edward Hvarregaard wrote:
> > I am having trouble getting started in C++ I have done some programming in
> > PASCAL where I had no problem finding the commands needed to deal with
> > directories, files and attributes. where can I find the similar commands
> > for C++ ?
> >
> > The startup code I need must do the following
> >
> > If "C:\SSF\ProgramFiles\Exch.txt" does not exist
> > then Setup
> >
> > Setup needs to be a function that creates missing path elements and an
> > empty "Exch.txt" file


> If boost filesystem doesn't meet your needs, use the C filesystem
> interface provided by your platform.


Perhaps a bit of extra information, extending on what Ian Collins
wrote, may help: not all systems have a notion of directories
(or files) in the sense you're probably used to. And if C++
would require functions to exist that handle directories and
files in the manner you were expecting it there couldn't be a
C++ compiler for those kinds of systems. Thus such functions
weren't made an integral part of C++ (Pascal may be able to
deal with this problem in a different way since it was origi-
nally intended as a "learning language" and probably wasn't
meant to be available on somewhat more "exotic" systems).

So you either have to use the functions that your system
supplies you with for these purposes. Since it looks a bit
as if you're using Windows perhaps the information at

http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx

(and below, especially "Directory Managment" and "File Managment")
could be useful for you. Otherwise asking in a newsgroup about
programming under Windows could be a useful option.

But if you want to be more system-inpedendent then there's
the boost library ian mentioned that tries to do just that,
see

http://www.boost.org/doc/libs/1_41_0.../doc/index.htm

Regards, Jens
--
\ Jens Thoms Toerring ___
\__________________________ http://toerring.de
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      08-16-2011
Nobody <> wrote:
> The C++ language isn't tied to a specific platform. Consequently, it
> doesn't include features which are platform-specific. Directories are such
> a feature: not all platforms have them, and those that do can have wildly
> different semantics.
>
> So you need to use either a third-party library (e.g. boost::filesystem),


I can't help but to notice the slight contradiction: First it's pointed
out that handling directories and file listings is very system-dependent
(and hence by implication impossible to write code for in a portable way),
and immediately after that a portable generic file system library is
suggested.

Anyways, is there a reason why the C++ standard couldn't include a
library similar to boost::filesystem?
 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      08-16-2011
Juha Nieminen wrote:

> Anyways, is there a reason why the C++ standard couldn't include a
> library similar to boost::filesystem?


There is a proposal pending for the next revision of the standard.
 
Reply With Quote
 
Jens Thoms Toerring
Guest
Posts: n/a
 
      08-16-2011
Juha Nieminen <> wrote:
> Nobody <> wrote:
> > The C++ language isn't tied to a specific platform. Consequently, it
> > doesn't include features which are platform-specific. Directories are such
> > a feature: not all platforms have them, and those that do can have wildly
> > different semantics.
> >
> > So you need to use either a third-party library (e.g. boost::filesystem),


> I can't help but to notice the slight contradiction: First it's pointed
> out that handling directories and file listings is very system-dependent
> (and hence by implication impossible to write code for in a portable way),
> and immediately after that a portable generic file system library is
> suggested.


> Anyways, is there a reason why the C++ standard couldn't include a
> library similar to boost::filesystem?


According to the documentation it is in the process of being made
part of the C++ standard:

A proposal, N1975, to include Boost.Filesystem in Technical
Report 2 has been accepted by the C++ Standards Committee.
The Boost.Filesystem library will stay in alignment with the
TR2 Filesystem proposal as it works its way through the TR2
process.

I guess that, due to the C background of C++ (C doesn't have
a portable interface for directory and file managment) it was
not considered to be necessary for C++ to have one. And then
this is a non-trivial problem and probably there wasn't a re-
ference implementation that really worked like Boost.Flile-
system seems to do and, as far as my understanding of the
standarduzation prozess goes, getting something into the
standard without a reasonable reference implementation normally
doesn't happen. And even with a reference implementation it's
still a long process...
Regards, Jens
--
\ Jens Thoms Toerring ___
\__________________________ http://toerring.de
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      08-16-2011
Juha Nieminen <> writes:
>Anyways, is there a reason why the C++ standard couldn't include a
>library similar to boost::filesystem?


See also:

http://www.purl.org/stefan_ram/pub/c..._extensions_en

(first published 2003-09-02).

 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      08-16-2011
On Tue, 2011-08-16, Edward Hvarregaard wrote:
> newby here
>
> I am having trouble getting started in C++ I have done some programming in
> PASCAL where I had no problem finding the commands needed to deal with
> directories, files and attributes.


Which Pascal? I doubt Wirth's original Pascal had such things -- IIRC
it barely had strings.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      08-16-2011
On Tue, 2011-08-16, Juha Nieminen wrote:
> Nobody <> wrote:
>> The C++ language isn't tied to a specific platform. Consequently, it
>> doesn't include features which are platform-specific. Directories are such
>> a feature: not all platforms have them, and those that do can have wildly
>> different semantics.
>>
>> So you need to use either a third-party library (e.g. boost::filesystem),

>
> I can't help but to notice the slight contradiction: First it's pointed
> out that handling directories and file listings is very system-dependent
> (and hence by implication impossible to write code for in a portable way),
> and immediately after that a portable generic file system library is
> suggested.


Perhaps boost::filesystem doesn't have to work /everywhere/ where
there's a C++ compiler? I haven't checked.

(Personally I don't think I'd use a standard and generic file system
interface if there was one -- not unless there was a straight 1:1
mapping to the Unix file system. That's the single target environment
for my code, and I know it well.)

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Directories and Physical directories Paul M Fin MCAD 4 06-27-2008 07:50 PM
Extracting Directories and Sub Directories and Counting Ron Smith Perl Misc 5 11-02-2004 11:23 PM
Getting all directories/files from current directory and using -d flag for the directories Adam Petrie Perl Misc 8 10-11-2004 01:28 PM
How to map Project directories to Production sub-directories Joel Finkel ASP .Net 0 09-12-2003 06:47 PM
Using virtual directories for common directories (scripts, images, styles, etc.) Jeffry van de Vuurst ASP .Net 2 07-30-2003 07:00 PM



Advertisments