0
|
1 <html>
|
|
2 <head>
|
|
3 <title>MayaChemTools:Documentation:FileUtil.pm</title>
|
|
4 <meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
|
|
6 </head>
|
|
7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
|
|
8 <br/>
|
|
9 <center>
|
|
10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
|
|
11 </center>
|
|
12 <br/>
|
|
13 <div class="DocNav">
|
|
14 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./SDFileIO.html" title="SDFileIO.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./AtomNeighborhoodsFingerprints.html" title="AtomNeighborhoodsFingerprints.html">Next</a></td><td width="34%" align="middle"><strong>FileUtil.pm</strong></td><td width="33%" align="right"><a href="././code/FileUtil.html" title="View source code">Code</a> | <a href="./../pdf/FileUtil.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/FileUtil.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/FileUtil.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/FileUtil.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
|
|
16 </table>
|
|
17 </div>
|
|
18 <p>
|
|
19 </p>
|
|
20 <h2>NAME</h2>
|
|
21 <p>FileUtil</p>
|
|
22 <p>
|
|
23 </p>
|
|
24 <h2>SYNOPSIS</h2>
|
|
25 <p>use FileUtil;</p>
|
|
26 <p>use FileUtil qw(:all);</p>
|
|
27 <p>
|
|
28 </p>
|
|
29 <h2>DESCRIPTION</h2>
|
|
30 <p><strong>FileUtil</strong> module provides the following functions:</p>
|
|
31 <p> <a href="#checkfiletype">CheckFileType</a>, <a href="#convertcygwinpath">ConvertCygwinPath</a>, <a href="#expandfilenames">ExpandFileNames</a>, <a href="#filemodificationtimeanddate">FileModificationTimeAndDate</a>
|
|
32 , <a href="#filesize">FileSize</a>, <a href="#formatfilesize">FormatFileSize</a>, <a href="#formattedfilemodificationtimeanddate">FormattedFileModificationTimeAndDate</a>
|
|
33 , <a href="#getmayachemtoolslibdirname">GetMayaChemToolsLibDirName</a>, <a href="#getusagefrompod">GetUsageFromPod</a>, <a href="#parsefilename">ParseFileName</a>
|
|
34 </p><p>
|
|
35 </p>
|
|
36 <h2>FUNCTIONS</h2>
|
|
37 <dl>
|
|
38 <dt><strong><a name="checkfiletype" class="item"><strong>CheckFileType</strong></a></strong></dt>
|
|
39 <dd>
|
|
40 <div class="OptionsBox">
|
|
41 $Status = CheckFileType($FileName, $FileExts);</div>
|
|
42 <p>Based on <em>FileExts</em>, decides type of <em>FileName</em> and return 1 or 0.</p>
|
|
43 </dd>
|
|
44 <dt><strong><a name="convertcygwinpath" class="item"><strong>ConvertCygwinPath</strong></a></strong></dt>
|
|
45 <dd>
|
|
46 <div class="OptionsBox">
|
|
47 $NewPath = ConvertCygwinPath($Path);</div>
|
|
48 <p>Check to see whether <em>Path</em> contains any Cygwin drive specification and convert
|
|
49 it into Windows path.</p>
|
|
50 </dd>
|
|
51 <dt><strong><a name="expandfilenames" class="item"><strong>ExpandFileNames</strong></a></strong></dt>
|
|
52 <dd>
|
|
53 <div class="OptionsBox">
|
|
54 @FilesList = ExpandFileNames(\@Files, $FileExts);
|
|
55 <br/> @FilesList = ExpandFileNames(\@Files, $FileExts, $IncludeDirName);</div>
|
|
56 <p>For each directory name or wild card file name in <em>Files</em>, generate all file names which
|
|
57 correspond to the specification along with match to any extensions in <em>FileExts</em> and return an
|
|
58 array <strong>FileList</strong> containing these file names and other names. <em>IncludeDirName</em> controls
|
|
59 controls whether directory prefixes are included in expanded file names. Default is to always
|
|
60 append directory name before expanded file name.</p>
|
|
61 <p>Notes:</p>
|
|
62 <div class="OptionsBox">
|
|
63 . Multiple file extensions are delimited by spaces.
|
|
64 <br/> . Wild card, *, is supported in directory and file names along with file
|
|
65 extensions.
|
|
66 <br/> . For a specified directory name in the files list, all the files in the
|
|
67 directory are retrieved using Perl opendir function and files filtered using file
|
|
68 extensions. The file names "." and ".." returned by opendir are ignored.
|
|
69 <br/> . For file names containing wild cards with and without any explicit file
|
|
70 extension specification in the file name, all the files in the directory are retrieved
|
|
71 using Perl opendir function and files filtered using file name along with any
|
|
72 file extension. The file names "." and ".." returned by opendir are ignored.</div>
|
|
73 </dd>
|
|
74 <dt><strong><a name="formattedfilemodificationtimeanddate" class="item"><strong>FormattedFileModificationTimeAndDate</strong></a></strong></dt>
|
|
75 <dd>
|
|
76 <div class="OptionsBox">
|
|
77 ($TimeString, $DateString) =
|
|
78 FormattedFileModificationTimeAndDate($FileName);</div>
|
|
79 <p>Returns a formatted time and date string corresponding to <em>FileName</em> modification time.</p>
|
|
80 </dd>
|
|
81 <dt><strong><a name="filemodificationtimeanddate" class="item"><strong>FileModificationTimeAndDate</strong></a></strong></dt>
|
|
82 <dd>
|
|
83 <div class="OptionsBox">
|
|
84 ($Hours, $Mins, $Secs, $DayName, $MonthName, $Month, $Year) =
|
|
85 FileModificationTimeAndDate($FileName);</div>
|
|
86 <p>Returns file modification time and date values for specified <em>FileName</em>.</p>
|
|
87 </dd>
|
|
88 <dt><strong><a name="formatfilesize" class="item"><strong>FormatFileSize</strong></a></strong></dt>
|
|
89 <dd>
|
|
90 <div class="OptionsBox">
|
|
91 $FormattedSize= FormatFileSize($Size, [$Precision]);</div>
|
|
92 <p>Formats the file size in bytes to human readable value and returns a formatted file
|
|
93 size string.</p>
|
|
94 </dd>
|
|
95 <dt><strong><a name="filesize" class="item"><strong>FileSize</strong></a></strong></dt>
|
|
96 <dd>
|
|
97 <div class="OptionsBox">
|
|
98 $Size= FileSize($FileName);</div>
|
|
99 <p>Returns size of <em>FileName</em> in bytes</p>
|
|
100 </dd>
|
|
101 <dt><strong><a name="getmayachemtoolslibdirname" class="item"><strong>GetMayaChemToolsLibDirName</strong></a></strong></dt>
|
|
102 <dd>
|
|
103 <div class="OptionsBox">
|
|
104 $MayaChemToolsLibDir = GetMayaChemToolsLibDirName();</div>
|
|
105 <p>Returns MayaChemTools lib directory name by parsing <strong>INC</strong> values to extract
|
|
106 <strong>MAYACHEMTOOLS/lib</strong> directory location: first entry in <strong>INC</strong> path should contain
|
|
107 MayaChemTools lib location.</p>
|
|
108 </dd>
|
|
109 <dt><strong><a name="getusagefrompod" class="item"><strong>GetUsageFromPod</strong></a></strong></dt>
|
|
110 <dd>
|
|
111 <div class="OptionsBox">
|
|
112 $ScriptUsage = GetUsageFromPod($AbsoluteScriptPath);</div>
|
|
113 <p>Generates a <strong>ScriptUsage</strong> string from pod documentation in the script file using
|
|
114 pod2text or perdoc.bat Perl utitities.</p>
|
|
115 </dd>
|
|
116 <dt><strong><a name="parsefilename" class="item"><strong>ParseFileName</strong></a></strong></dt>
|
|
117 <dd>
|
|
118 <div class="OptionsBox">
|
|
119 ($FileDir, $FileName, $FileExt) = ParseFileName($FullFileName);</div>
|
|
120 <p>Splits <em>FullFileName</em> into directory name, file name, and extension. <strong>FileDir</strong> is
|
|
121 set to current directory for absent directory name in <em>FullFileName</em>. And <em>FileExt</em>
|
|
122 is set to NULL string for <em>FullFileName</em> without any extension.</p>
|
|
123 <p>This function doesn't perform checking ragarding the presence of the directory <em>FileDir</em>
|
|
124 and <em>FullFileName</em> and the <em>FullFileName</em> without any extension is assumed to be
|
|
125 a file instead of a directory.</p>
|
|
126 </dd>
|
|
127 </dl>
|
|
128 <p>
|
|
129 </p>
|
|
130 <h2>AUTHOR</h2>
|
|
131 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
|
|
132 <p>
|
|
133 </p>
|
|
134 <h2>SEE ALSO</h2>
|
|
135 <p><a href="./TextUtil.html">TextUtil.pm</a>, <a href="./TimeUtil.html">TimeUtil.pm</a>
|
|
136 </p>
|
|
137 <p>
|
|
138 </p>
|
|
139 <h2>COPYRIGHT</h2>
|
|
140 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
|
|
141 <p>This file is part of MayaChemTools.</p>
|
|
142 <p>MayaChemTools is free software; you can redistribute it and/or modify it under
|
|
143 the terms of the GNU Lesser General Public License as published by the Free
|
|
144 Software Foundation; either version 3 of the License, or (at your option)
|
|
145 any later version.</p>
|
|
146 <p> </p><p> </p><div class="DocNav">
|
|
147 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
148 <tr align="left" valign="top"><td width="33%" align="left"><a href="./SDFileIO.html" title="SDFileIO.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./AtomNeighborhoodsFingerprints.html" title="AtomNeighborhoodsFingerprints.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>FileUtil.pm</strong></td></tr>
|
|
149 </table>
|
|
150 </div>
|
|
151 <br />
|
|
152 <center>
|
|
153 <img src="../../images/h2o2.png">
|
|
154 </center>
|
|
155 </body>
|
|
156 </html>
|