 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rune Allnor Guest
|
Posted: Sun May 20, 2007 12:26 am Post subject: Disk/directory access: Least unportable method? |
|
|
Hi all.
My application needs to work on directory structures with
several levels. I do my work on a Win32 system, but I would
like to keep my options open for porting to other systems.
The first concern is to start from a given 'root' directory
and scan subdirectories recursively, the second is to
obtain lists of files with sizes which are stored in any
one directory. Basically I need to do in C++ code what
I used to do with 'ls' on the UNIX command line.
In my Win32 compiler suite I have found 'dirent.h,' which
seems to contain some functions which might become
useful. According to the documentation those routines
are standard for Win23 and POSIX, but not ANSI C/C++.
In the past I have made an effort to comply with ANSI
or ISO standards wherever possible, in order to maintain
code portability between platforms.
What are the best ways to obtain the required disk access
functionality without obstructing future porting of code?
The Qt library is not an option, since I can only afford the
OpenSource edition, which is hard-wired to some weird
(what Win32 is concerned) non-commercial compiler,
and I need to use my commercial compiler in order to
get acces to COM automation.
Rune
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Denise Kleingeist Guest
|
Posted: Sun May 20, 2007 6:57 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
Hello Rune!
On May 20, 2:26 am, Rune Allnor <all...@tele.ntnu.no> wrote:
| Quote: | My application needs to work on directory structures with
several levels. I do my work on a Win32 system, but I would
like to keep my options open for porting to other systems.
|
Use the file system library from TR1: this will become part of
the next revision of the C++ standard. If you can't afford an
implementation of TR1 now, you can use Boost's file system
library (although I would think that it would be time to look
for a new job because Dinkumware's implementation isn't that
expensive): the TR1 version is based on the Boost one and it
should be a matter of redefining a namespace alias to obtain
the one shipping with your compile once it becomes available.
Good luck, Denise
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
myork Guest
|
Posted: Sun May 20, 2007 6:59 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
boost: www.boost.org
Boost has a file system library:
http://www.boost.org/libs/filesystem/doc/index.htm
Though technically boost is not a standard, it is used by the C++ as a
breeding place for new concepts that people want to be included in the
standard. And several people on the C++ standards committee are active
members of boost.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Markus Schoder Guest
|
Posted: Sun May 20, 2007 6:59 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
On Sat, 19 May 2007 18:26:38 -0600, Rune Allnor wrote:
| Quote: | My application needs to work on directory structures with several
levels. I do my work on a Win32 system, but I would like to keep my
options open for porting to other systems.
|
On http://www.boost.org look for the boost filesystem library.
| Quote: | What are the best ways to obtain the required disk access functionality
without obstructing future porting of code? The Qt library is not an
option, since I can only afford the OpenSource edition, which is
hard-wired to some weird (what Win32 is concerned) non-commercial
compiler, and I need to use my commercial compiler in order to get acces
to COM automation.
|
There is a project that adds Visual Studio support to the free edition Qt
library. Google for it.
--
Markus Schoder
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Marcus Kwok Guest
|
Posted: Sun May 20, 2007 6:59 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
Rune Allnor <allnor (AT) tele (DOT) ntnu.no> wrote:
| Quote: | My application needs to work on directory structures with
several levels. I do my work on a Win32 system, but I would
like to keep my options open for porting to other systems.
The first concern is to start from a given 'root' directory
and scan subdirectories recursively, the second is to
obtain lists of files with sizes which are stored in any
one directory. Basically I need to do in C++ code what
I used to do with 'ls' on the UNIX command line.
In my Win32 compiler suite I have found 'dirent.h,' which
seems to contain some functions which might become
useful. According to the documentation those routines
are standard for Win23 and POSIX, but not ANSI C/C++.
In the past I have made an effort to comply with ANSI
or ISO standards wherever possible, in order to maintain
code portability between platforms.
What are the best ways to obtain the required disk access
functionality without obstructing future porting of code?
The Qt library is not an option, since I can only afford the
OpenSource edition, which is hard-wired to some weird
(what Win32 is concerned) non-commercial compiler,
and I need to use my commercial compiler in order to
get acces to COM automation.
|
Boost has a filesystem library that might be useful for what you need.
http://www.boost.org/
--
Marcus Kwok
Replace 'invalid' with 'net' to reply
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Sun May 20, 2007 7:00 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
On May 20, 2:26 am, Rune Allnor <all...@tele.ntnu.no> wrote:
| Quote: | What are the best ways to obtain the required disk access
functionality without obstructing future porting of code?
|
Use a library such as boost filesystem.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Thomas J. Gritzan Guest
|
Posted: Sun May 20, 2007 7:00 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
Rune Allnor wrote:
| Quote: | My application needs to work on directory structures with
several levels. I do my work on a Win32 system, but I would
like to keep my options open for porting to other systems.
The first concern is to start from a given 'root' directory
and scan subdirectories recursively, the second is to
obtain lists of files with sizes which are stored in any
one directory. Basically I need to do in C++ code what
I used to do with 'ls' on the UNIX command line.
In my Win32 compiler suite I have found 'dirent.h,' which
seems to contain some functions which might become
useful.
[...] |
Since there's no way in standard C++ to do that, you could use the POSIX
library or I suggest boost.filesystem which has good changes to make it
into one of the next C++ standards.
--
Thomas
http://www.netmeister.org/news/learn2quote.html
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
John Moeller Guest
|
Posted: Sun May 20, 2007 7:00 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
Rune Allnor wrote:
| Quote: | ...
The first concern is to start from a given 'root' directory
and scan subdirectories recursively, the second is to
obtain lists of files with sizes which are stored in any
one directory. Basically I need to do in C++ code what
I used to do with 'ls' on the UNIX command line.
...
What are the best ways to obtain the required disk access
functionality without obstructing future porting of code?
The Qt library is not an option, since I can only afford the
OpenSource edition, which is hard-wired to some weird
(what Win32 is concerned) non-commercial compiler,
and I need to use my commercial compiler in order to
get acces to COM automation.
|
Qt is way too heavy for what you want anyway. Have you tried
Boost.Filesystem?
http://www.boost.org/libs/filesystem/doc/index.htm
I haven't used it yet, but I looked into it. It should serve your
needs. Boost is also committed to cross-platform compatibility.
--
John Moeller
fishcorn (AT) gmail (DOT) com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Carl Barron Guest
|
Posted: Sun May 20, 2007 7:00 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
Rune Allnor <allnor (AT) tele (DOT) ntnu.no> wrote:
| Quote: |
In my Win32 compiler suite I have found 'dirent.h,' which
seems to contain some functions which might become
useful. According to the documentation those routines
are standard for Win23 and POSIX, but not ANSI C/C++.
In the past I have made an effort to comply with ANSI
or ISO standards wherever possible, in order to maintain
code portability between platforms.
Thw ansi C or C++ standard does not have a concept of directory of |
files, but most unix's provide dirent.h . If a platform does not have a
dirent.h , it is fairly easy to implement if the os supports diretories,
and if it does not your application won't work. [most mainstream os'es
support directories, but some 'old ones' don't] My advice is use
dirent.h's portable functions,
with the C API as then you are almost certain to have no porting
problems, except some 'wierd' system without directories. Stick
to opendir(), readdir(), closedir() as some implementations don't like
seekdir(),telldir(),rewinddir(), if reasonable. Examine the POSIX docs
as these are probably what a non POSIX system will emulate.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Sun May 20, 2007 3:34 pm Post subject: Re: Disk/directory access: Least unportable method? |
|
|
Denise Kleingeist wrote:
| Quote: |
Use the file system library from TR1: this will become part of
the next revision of the C++ standard.
|
The file system library isn't in TR1. It's in TR2 (or maybe just on the
list to be added to TR2), which has just barely gotten started. No
document yet. It's not currently on the list for the next standard. So
Boost is, indeed, your best bet: that's where it came from.
--
-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
sss.zhou@gmail.com Guest
|
Posted: Sun May 20, 2007 3:35 pm Post subject: Re: Disk/directory access: Least unportable method? |
|
|
On May 20, 8:26 am, Rune Allnor <all...@tele.ntnu.no> wrote:
| Quote: | The Qt library is not an option, since I can only afford the
OpenSource edition, which is hard-wired to some weird
(what Win32 is concerned) non-commercial compiler,
and I need to use my commercial compiler in order to
get acces to COM automation.
|
Qt can work successfully with VC6 or VS2003 and QFile/QDir can be used
free.
If you don't have Ms complier, I learn that Eciplse + CDT(C++
Development Toolkit) is able to compliee Qt codes. Becuase I use the
"Qt4 commercial version" + VS2003 all the while, so I am sorry for can
not provide more advice abou it.
I think Qt library is a good way when C++ doesn't contain the standard
of file because Qt library teams will maintains their codes for
different OS. QDir also has very convenience functions for your
requirements. (Just call QDir::entryInfoList() will get all you want.)
Sorry for my bad english, I wish you can understand.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Sun May 20, 2007 11:44 pm Post subject: Re: Disk/directory access: Least unportable method? |
|
|
On May 20, 2:26 am, Rune Allnor <all...@tele.ntnu.no> wrote:
| Quote: | The Qt library is not an option, since I can only afford the
OpenSource edition, which is hard-wired to some weird
(what Win32 is concerned) non-commercial compiler
|
How is it hardwired?
Qt is released under the GPL. Nothing prevents you from using it with
a commercial compiler and use it for commercial products.
However, that means that if you want to distribute your application,
it will have to be under the terms of a GPL-compatible license.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Rune Allnor Guest
|
Posted: Mon May 21, 2007 4:56 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
On 21 May, 01:44, Mathias Gaunard <loufo...@gmail.com> wrote:
| Quote: | On May 20, 2:26 am, Rune Allnor <all...@tele.ntnu.no> wrote:
The Qt library is not an option, since I can only afford the
OpenSource edition, which is hard-wired to some weird
(what Win32 is concerned) non-commercial compiler
How is it hardwired?
|
The version I have was distributed on a CD with the Qt4 book
by Blanchette(sp?). The CD contained the MinGW (?) compiler
along with all the libraries on a binary format which was
ported more or less dierctly from UNIX. Maybe it is
straight-forward to convert those binaries to a format
which is compatible with standard Win32 DLLs, but I don't
know how to do that. Nor am I very interested in learning
it, for that matter.
Rune
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Mathias Gaunard Guest
|
Posted: Tue May 22, 2007 12:11 am Post subject: Re: Disk/directory access: Least unportable method? |
|
|
On May 21, 6:56 am, Rune Allnor <all...@tele.ntnu.no> wrote:
| Quote: | The version I have was distributed on a CD with the Qt4 book
by Blanchette(sp?). The CD contained the MinGW (?) compiler
along with all the libraries on a binary format which was
ported more or less dierctly from UNIX.
|
MinGW is GCC for Windows.
For marketing purposes, Trolltech doesn't distribute a precompiled
version of Qt for Visual C++.
But you've got the source. Just compile and set up the environment
yourself for the compiler of your choice.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|