Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [C++] Ottenere la data di Creazione di un File

    Ciao..

    Vorei sapere un modo (o anche diversi modi) per ottenere la data di creazione di un file qualsiasi..

    So che ce anche la data dell'ultimo accesso e dell'ultima scrittura, a basta quella ci creazione...

    Grazie mille a tutti..

    Ciao..
    Il linguaggio migliore e quello che ti crei da solo...

  2. #2
    puoi usare la funzione stat()

    codice:
    #include <time.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <stdio.h>
    
    void main( void )
    {
       struct stat buf;
       int result;
       char buffer[] = "A line to output";
    
       /* Get data associated with "stat.c": */
       result = stat( "stat.c", &buf );
    
       /* Check if statistics are valid: */
       if( result != 0 )
          perror( "Problem getting information" );
       else
       {
          /* Output some of the statistics: */
          printf( "File size        : %ld\n", buf.st_size );
          printf( "Time modified    : %s", ctime( &buf.st_mtime ));
          printf( "Time created     : %s", ctime( &buf.st_ctime ));
          printf( "Time last access : %s", ctime( &buf.st_atime ));
       }
    }
    Nota che su linux se usi ext2/ext3 non puoi avere la data di creazione di un file, in quel caso st_ctime rappresenta la data di ultimo cambiamento "time of last change"

    http://www.rt.com/man/stat.2.html

    Se il file è già stato aperto con open() o fopen(), puoi usare in quel caso la funzione:
    int fstat(int filedes, struct stat *buf);

  3. #3
    Ottimo...

    Garzie Mille...
    Il linguaggio migliore e quello che ti crei da solo...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.