Solved

How do I modify the file modification timestamp using QT

Posted on 2009-07-13
1
2,143 Views
Last Modified: 2013-11-23
I want to build a platform independent file copying tool using qt and need to modify file parameters like creation time and so on.

Any ideas?
0
Comment
Question by:IvoBurkart
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 24840316
QT has no special way to do that (you will find that all methods of QFile and QFileInf that deal with times are 'const'), but 'utime()' is POSIX and therefore portable anyway (see e.g. the related discussion at http://lists.trolltech.com/qt-interest/2005-03/msg01350.html#msg01350 - also the original source of 'touch' in http://ftp.gnu.org/gnu/coreutils/coreutils-5.0.tar.gz), so you basically could
/* UTIME.C: This program uses _utime to set the

 * file-modification time to the current time.

 */
 

#include <stdio.h>

#include <stdlib.h>

#include <sys/types.h>

#ifdef WIN32

#include <sys/utime.h>

#define SHOWCMD "dir utime.c"

#else

#define _utime utime

#define _utimbuf utimbuf

#include <utime.h>

#define SHOWCMD "ls -l utime.c"

#endif
 

void main( void )

{

   /* Show file time before and after. */

   system( SHOWCMD );

   if( _utime( "utime.c", NULL ) == -1 )

      perror( "_utime failed\n" );

   else

      printf( "File time modified\n" );

   system( SHOWCMD );

}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This is about my first experience with programming Arduino.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now