5,550,131 members and growing! (19,831 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Tools with source code     Intermediate

Touch for Windows

By Jörgen Sigvardsson

This is the touch tool ported to Windows
VC7, VC7.1, C++Windows, Win2K, WinXPVS.NET2003, Visual Studio, Dev

Posted: 26 Nov 2002
Updated: 15 Feb 2006
Views: 144,271
Bookmarked: 32 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
35 votes for this Article.
Popularity: 5.65 Rating: 3.66 out of 5
6 votes, 18.2%
1
3 votes, 9.1%
2
3 votes, 9.1%
3
4 votes, 12.1%
4
17 votes, 51.5%
5

Introduction

I've seen at least two people asking for a Windows version of the UNIX utility touch this past week. So here it is: a Windows version of the OpenBSD touch command. It's not fully compatible as my utility can only touch one file at a time and does not support the -f argument (force touch, ignoring access rights). However, my version supports altering modification, access and creation time, while the OpenBSD version only supports alteration of access and modification time.

If you have a need for a touch utility which ignores access rights and can handle multiple files (including globing), tell me and I'll see what I can do.

I've also made sure it's UNICODE compatible, but as my system is as western as it gets, I haven't really been able to test it. If you find anything fishy when compiled as a UNICODE binary, please let me know.

What Does It Do?

For those who don't know, here's a simple explanation: It updates the dates associated with a file to whatever you want it to be. It can change access, modification and creation dates. You as a user can update them independently of each other, you can update them with any possible date. Dates can be now, user specified or copied from another file. If you try to touch a file which does not exist, this command will create it for you (empty of course).

You can always run touch -h for help.

Where's the Article?

This is not rocket science. I'm basically just using simple Win32 API functions. Writing an article about it would be like reciting the MSDN documentation. If you are interested in how it works, use the source - it's not big and it doesn't really contain any surprises.

License Grant

You are granted a license to use the code for whatever purpose, if and only if the following conditions are met:

  • You may expect no warranties from my part. If you break something, you fix it.
  • If we meet some day in the flesh, you may buy me a beer of my choice. This is not a requirement, but it would be a very nice thing to do and I would appreciate it. If your religion prohibits you from buying any alcohol, even if not for yourself, a coke is fine or whatever well testing beverage which you find morally and ethically acceptable.

Revision history

  • 2002-11-28 - Initial version.
  • 2004-04-03 - Bugfixes: UNICODE, argument parsing, daylight saving, time string parsing.
  • 2006-02-15 - Wildcard support, much thanks to PhaetonTheGreat!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jörgen Sigvardsson


Professional C++ programmer with a masters degree in Computer Science. Not much else to say really.

Jörgen firmly believes that people who refer to themselves in third person, are mentally challenged.

If you are a fellow Shorinji Kempo kenshi, don't hesitate to send me a line.
Occupation: Web Developer
Location: Sweden Sweden

Other popular Applications & Tools articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 43 (Total in Forum: 43) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralShell integration [modified]memberCBoland13:52 31 Jan '07  
GeneralRe: Shell integrationmemberJoergen Sigvardsson23:33 31 Jan '07  
GeneralWell Done - it just works !!memberChrisRRRR1:59 31 Jan '07  
GeneralRe: Well Done - it just works !!memberJoergen Sigvardsson23:32 31 Jan '07  
GeneralRecursionmemberBleary Eye6:54 28 Nov '06  
GeneralDoes not create files if it does not exist.membergorfou8:22 7 Sep '06  
GeneralThanks, Jorgen!memberMy other CP account20:04 18 Jun '06  
GeneralWhy not to use original touch?memberPaulius Maruška11:39 21 Feb '06  
GeneralRe: Why not to use original touch?memberJörgen Sigvardsson11:42 21 Feb '06  
GeneralRe: Why not to use original touch?memberPaulius Maruška11:48 21 Feb '06  
GeneralFor touch with handling multiple files at once...memberirnis4:13 21 Feb '06  
GeneralThank you!memberPhaetonTheGreat!19:56 14 Feb '06  
GeneralRe: Thank you!memberJörgen Sigvardsson21:32 14 Feb '06  
GeneralRe: Thank you!memberJörgen Sigvardsson21:34 14 Feb '06  
GeneralRe: Thank you!memberPhaetonTheGreat!1:43 15 Feb '06  
GeneralRe: Thank you!memberJörgen Sigvardsson2:04 15 Feb '06  
GeneralGood, but look at ....memberamauta12:43 2 Feb '05  
GeneralRe: Good, but look at ....membergorfou8:19 7 Sep '06  
GeneralI was looking for a good touch :)memberAvinoam Sapir22:28 19 Jan '05  
Generalquestionmemberzetroooooo20:44 3 Sep '04  
GeneralRe: questionmemberJörgen Sigvardsson23:53 3 Sep '04  
GeneralDirectory Support?sussAdam P.12:33 30 May '04  
AnswerRe: Directory Support?memberDavidLowndes@msn23:37 20 Feb '06  
GeneralProblems with Secondsmembermario543235:10 3 Apr '04  
GeneralRe: Problems with SecondsmemberJörgen Sigvardsson7:06 3 Apr '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 15 Feb 2006
Editor: Smitha Vijayan
Copyright 2002 by Jörgen Sigvardsson
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project