You are here:

C++/SystemTimetoFileTime API in QNX

Advertisement


Question
Hi,
I need the equivalent API for SystemTimeToFileTime() in QNX. This is necessary for me to convert the system time into File time.

Please tell me how to do the same.


Regards,
Amol

Answer
Well you do not state _what_ sort of FILETIME Win32 struct equivalent you want to use on QNX,  - which I take to be a POSIX/UN*X like system nor for that matter what you intend to do with such a time value.

Assuming you wish to set the access and/or modification times of a file the easiest thing to do is to set up one or two C/C++ standard library tm struct objects and use the C/C++ standard library function mktime to convert them to time_t values (include <ctime> or <time.h> for C) which you use to set the actime and modtime members of a POSIX/UN*X utimbuf struct and use it to pass to utime together with the pathname of the file who's times you wish to update (include <sys/types.h> and <utime.h> - see http://www.qnx.com/developers/docs/6.4.0/neutrino/lib_ref/u/utime.html for more information).

The above will generally allow an accuracy to 1 second - depending on the resolution of time_t values for QNX - which as an operating system I have never used and not explicitly mentioned in the documentation for time_t for <time.h> (see http://www.qnx.com/developers/docs/6.3.0SP3/dinkum_en/c99/time.html) I cannot comment on further - sorry. However the tm struct does not allow times less than a second anyway.

If you require further accuracy then you will have to think of something else - e.g. getting the time using gettimeofday and using a timeval struct object with utimes (include <sys/time.h>) (see http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/g/gettimeofday.html and http://www.qnx.net/developers/docs/6.3.0SP3/neutrino/lib_ref/u/utimes.html).

Now I located the above information from a standing start in about 10 to 15 minutes using nothing more than a web browser and some queries to Google (well two browsers as the MSDN Library site requires MSIE and it seems I require an updated plug in for Firefox to handle such situations). In the future please do likewise and do not use me as an unpaid research assistant.

If this is not what you were looking for then I suggest you start making use of Google or other search facilities and the available documentation for QNX - you should of course get a good grasp of what the existing Win32 code is doing if you are trying to convert some existing Windows specific code - why is it using SystemTimetoFileTime - where is it getting the system time from, what does it need the file time for etc.  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Ralph McArdell

Expertise

I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.

Experience

My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at http://www.open-std.org/jtc1/sc22/wg21/.

Education/Credentials

©2012 About.com, a part of The New York Times Company. All rights reserved.