Win32::IdentifyFile - Perl extension for to obtain an identity for an NTFS file


  use Win32::IdentifyFile qw(:all);

  @info = IdentifyFile(filename);
  $info = IdentifyFile(filename);


This module returns three items which together uniquely identify a file or directory on Microsoft Windows NTFS. The identity fulfils a similar role to an inode number on UNIX file systems.

The filename specified may be a file or directory, and may be in conventional Windows, relative, or UNC (Universal Naming Convention), formats.

The information returned by IdentifyFile is as follows: Volume Serial Number, File Index High, File Index Low. In list context these are returned as a list. In scalar context these are returned as a single string, joined by ':';

Just getting this information could result in a race condition. The file could be deleted, possibly by another process, between getting the information and using it in a test. Worse, another file might be created with the same file index meanwhile. To prevent this scenario, files (or directories) are opened internally by IdentifyFile(), and kept open until CloseIdentifyFile() is called (files are not physically deleted until all open file handles are closed).

It is important to call CloseIdentifyFile() in order to avoid a resource leak. Only one call is required, regardless of the number of times IdentifyFile() is called.


None by default.




Clive Darke, <> From a suggestion by 'grinder'


Copyright (C) 2008 by Clive Darke

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.