Menu

#7 Set file info

open
nobody
None
5
2002-08-15
2002-08-15
Tom Arn
No

There is a File.Info() function that reads the file
properties, but there is no way to modity them.

The (suggested) File.SetInfo() function should allow set
the file properties like attributes and datetimes but of
course the file size and directory flag should be ignored.

Discussion

  • Jim

    Jim - 2002-08-15

    Logged In: YES
    user_id=406388

    Added a file set attribute comand 'setatt'.

    e.g. f.setatt("C:\test.txt", file.FILE_HIDDEN)

    also added 5 new constants

    FILE_HIDDEN
    FILE_SYSTEM
    FILE_ARCHIVE
    FILE_NORMAL
    FILE_READONLY

     
  • A.H. Banen

    A.H. Banen - 2002-08-16

    Logged In: YES
    user_id=423153

    Jim,
    I like the function, but not how it is implemented. I think you
    should strive for input compatibility with the File.Info frame
    output which looks like this for a C:\Autoexec.bat:
    {
    created:"15-8-02 23:17:59",
    archive:true,
    directory:false,
    modified:"15-8-02 23:18:00",
    hidden:false,
    accessed:"16-8-02 0:00:00",
    size:2134,
    system:false,
    readonly:false,
    }
    I.e the user should be able to get the File.Info of a file,
    modify one or more of the values (provided this is allowed)
    and use the result with as file.Attributes( frame ) to set the
    wanted changes.
    In general new functions should be as compatible with
    existing functions to avoid user confusion and to make
    Dialect a messy amalgam of old and new functions. Etc.,
    etc. (I could babble on for hours :)
    Andr

     
  • Jim

    Jim - 2002-08-29

    Logged In: YES
    user_id=406388

    Andr,

    again you're right.
    (don't you get tired of being right all the time :-))

    When I get the (free time) AND (the motivation) I'll make it a
    {frame}.

    I've tried to implement a file date/time change function but am
    having trouble with the C++ FILETIME structure. Some else
    want to take a crack at it?

     
  • A.H. Banen

    A.H. Banen - 2002-08-30

    Logged In: YES
    user_id=423153

    Jim,
    You probably can use FileTimeToSystemTime and
    SystemTimeToFileTime (kernel32.dll) API calls to tame the
    FILETIME structure...
    Start to take a look here:
    http://www.vbapi.com/vbapi/ref/s/systemtime.html
    and look at the 'Used by' references.

    Andr

     
  • Tom Arn

    Tom Arn - 2002-11-16

    Logged In: YES
    user_id=462273

    In the MFC there is exactly what we need:
    CFile::GetStatus gets attributes and datetime of a file,
    CFile::SetStatus writes them back.

    Here is a little code snipped I took out of a larger function:

    setftime() // set file date and time
    {
    TCHAR unicode1[MAX_PATH]="file1.txt";
    CFile f;
    CFileStatus status;
    int nYear=2002, nMonth=11, nDay=15, nHour=15,
    nMin=34, nSec=45;

    CTime t(nYear,nMonth,nDay,nHour,nMin,nSec,-1);

    if (CFile::GetStatus( unicode1, status ))
    {
    status.m_mtime = t;
    CFile::SetStatus( unicode1, status );
    // ok
    }
    else // not ok
    }

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.