ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

futime.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   LGPL, See LGPL.txt in the top level directory
00003  * PROJECT:     ReactOS CRT library
00004  * FILE:        lib/sdk/crt/time/futime.c
00005  * PURPOSE:     Implementation of _futime
00006  * PROGRAMERS:  Wine team
00007  */
00008 
00009 /*
00010  * msvcrt.dll file functions
00011  *
00012  * Copyright 1996,1998 Marcus Meissner
00013  * Copyright 1996 Jukka Iivonen
00014  * Copyright 1997,2000 Uwe Bonnes
00015  * Copyright 2000 Jon Griffiths
00016  * Copyright 2004 Eric Pouech
00017  * Copyright 2004 Juan Lang
00018  *
00019  * This library is free software; you can redistribute it and/or
00020  * modify it under the terms of the GNU Lesser General Public
00021  * License as published by the Free Software Foundation; either
00022  * version 2.1 of the License, or (at your option) any later version.
00023  *
00024  * This library is distributed in the hope that it will be useful,
00025  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027  * Lesser General Public License for more details.
00028  *
00029  * You should have received a copy of the GNU Lesser General Public
00030  * License along with this library; if not, write to the Free Software
00031  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00032  *
00033  * TODO
00034  * Use the file flag hints O_SEQUENTIAL, O_RANDOM, O_SHORT_LIVED
00035  */
00036 
00037 #include <precomp.h>
00038 #define RC_INVOKED 1 // to prevent inline functions
00039 #include <time.h>
00040 #include <sys/utime.h>
00041 #include "bitsfixup.h"
00042 
00043 HANDLE fdtoh(int fd);
00044 
00045 /******************************************************************************
00046  * \name _futime
00047  * \brief Set a file's modification time.
00048  * \param [out] ptimeb Pointer to a structure of type struct _timeb that
00049  *        recieves the current time.
00050  * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
00051  */
00052 int
00053 _futime(int fd, struct _utimbuf *filetime)
00054 {
00055     HANDLE handle;
00056     FILETIME at, wt;
00057 
00058     handle = fdtoh(fd);
00059     if (handle == INVALID_HANDLE_VALUE)
00060     {
00061         return -1;
00062     }
00063 
00064     if (!filetime)
00065     {
00066         time_t currTime;
00067         _time(&currTime);
00068         RtlSecondsSince1970ToTime((ULONG)currTime,
00069                                   (LARGE_INTEGER *)&at);
00070         wt = at;
00071     }
00072     else
00073     {
00074         RtlSecondsSince1970ToTime((ULONG)filetime->actime,
00075                                   (LARGE_INTEGER *)&at);
00076         if (filetime->actime == filetime->modtime)
00077         {
00078             wt = at;
00079         }
00080         else
00081         {
00082             RtlSecondsSince1970ToTime((ULONG)filetime->modtime,
00083                                       (LARGE_INTEGER *)&wt);
00084         }
00085     }
00086 
00087     if (!SetFileTime(handle, NULL, &at, &wt))
00088     {
00089         _dosmaperr(GetLastError());
00090         return -1 ;
00091     }
00092 
00093     return 0;
00094 }

Generated on Sat May 26 2012 04:35:36 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.