[Qt-interest] OT: anyone know why QDir::mkpath() isn't static?
Atlant Schmidt
aschmidt at dekaresearch.com
Tue Apr 12 18:46:03 CEST 2011
Konstantin:
> But mkdir(2) is not portable.
So do it in Perl. Or PHP. ;-)
But meanwhile, I just compiled and executed
this code on my Windows/XP system and it had
the desired effect: it created "./foo/".
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
int main( int argc, char * argv[])
{
int status;
status = mkdir( "foo", 0644 );
printf( "Status = %d\n", status );
return(0);
}
So for many practical purposes, mkdir(2) is "portable
enough". The place you *MAY* get in trouble is if you're
coming from Windows to a Unix/Linux world. In some cases,
Windows mkdir() creates any needed-but-nonexistent
intervening directories whereas Unix/Linux (and, IIRC,
Perl and PHP) mkdir() never does that.
Atlant
-----Original Message-----
From: Konstantin Tokarev [mailto:annulen at yandex.ru]
Sent: Tuesday, April 12, 2011 12:30
To: Atlant Schmidt
Cc: 'Thiago Macieira'; qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] anyone know why QDir::mkpath() isn't static?
12.04.2011, 20:21, "Atlant Schmidt" <aschmidt at dekaresearch.com>:
> Paul:
>
> To expand on Thiago's rather cryptic response, in
> your case, the constructor and the method really
> *ARE* somewhat redundant but that's because you're
> not using the full beauty and grandeur [;-)] of
> the class.
>
> What you've really got when you construct a QDir
> is a sort of "cd" ("current working directory");
> you've got an object that now points to some
> directory that exists (or at least could exist)
> somewhere within your file system. You can then
> do all sorts of common manipulations to this
> working directory such as cd'ing downwards or
> upwards, extracting bits and pieces of the path,
> and so on.
>
> You can also create new paths (or individual
> directories) relative to this current working
> directory (and these can be absolute paths if
> the current working directory is an absolute
> path).
>
> It only feels redundant because you're doing
> essentially the simplest possible pair of
> operations where, yes, it may be "overkill"
> compared to mkdir(2).
But mkdir(2) is not portable.
--
Regards,
Konstantin
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
More information about the Qt-interest-old
mailing list