41 lines
1.8 KiB
C
41 lines
1.8 KiB
C
#ifndef _GEN_GET_FILE_H_
|
|
#define _GEN_GET_FILE_H_
|
|
|
|
|
|
/**
|
|
* \brief Get a file, using wget if necessary
|
|
*
|
|
* Takes a filename parameter.
|
|
* If this includes strftime type format specifiers, these are expanded using
|
|
* the current local time.
|
|
* Therefore any '%' characters in the name must be escaped (ie "%%").
|
|
*
|
|
* It can alternatively be the name of a script file prefixed by "cmd://"
|
|
* In this case, the script file should output a list of file paths on stdout,
|
|
* separated by whitespace (eg the output of a "find ... -print" command.
|
|
* Of course, it may need to download (or otherwise generate) the files first.
|
|
*
|
|
* Otherwise, if the filename is a url (including the substring "://" it is
|
|
* downloaded to the current directory using "wget -N".
|
|
* The "-N" checks that the remote file is not the same as a current version,
|
|
* and doesn't download the same file again. Without the option it would be
|
|
* downloaded with a "'1" (".2", ".3" etc) suffix added to the local name.
|
|
*
|
|
* The name of the (local) file (or whitespace separated list of files) after
|
|
* expanding any format specifiers is returned in the parameter..
|
|
*
|
|
* Useful strftime codes are likely to include:
|
|
* %d - day of month (01-31), %m - month (01-12), %y - year (00-99),
|
|
* %Y - year (eg 2011), %% - % sign.
|
|
*
|
|
* @param InFile input filename, may contain a url and/or format specifiers
|
|
* @param OutFile output filename for local (possibly downloaded) file, must be freed after use
|
|
* @param Verbosity if zero, output from wget will be suppressed. if >= 4 additional trace is output
|
|
* @return 0 if ok, else: -1 (malloc error), -2 (strftime error),
|
|
* -3 (wget or script command error), -4 (parameter error)
|
|
*/
|
|
int GenGetFile(const char *InFile, char **OutFile, int Verbosity);
|
|
|
|
|
|
#endif /* _GEN_GET_FILE_H_ */
|