diff options
author | Wanlong Gao <gaowanlong@cn.fujitsu.com> | 2012-10-14 14:32:36 +0800 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-10-17 11:12:07 +0100 |
commit | 773fa611411d457d4b18dcb171b333b7356c20ba (patch) | |
tree | ff1055646a9c9da48f0ea885ec824928e3ae4075 /generator | |
parent | 67e483689c086e22e9a3e038ea4e7285d9a0c4d2 (diff) | |
download | libguestfs-773fa611411d457d4b18dcb171b333b7356c20ba.tar.gz libguestfs-773fa611411d457d4b18dcb171b333b7356c20ba.tar.xz libguestfs-773fa611411d457d4b18dcb171b333b7356c20ba.zip |
NEW API: mktemp
Used to create temporary directory or file with an optional suffix.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
RWMJ:
- Split this out into a new file (daemon/mktemp.c).
- I don't see a reason to deprecate the mkdtemp function which
works fine. Instead remove complex dir-making code from the
new function.
- Test and fix the patch (missing close(fd)).
Diffstat (limited to 'generator')
-rw-r--r-- | generator/actions.ml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/generator/actions.ml b/generator/actions.ml index e7f4fe64..71aee379 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -10207,6 +10207,40 @@ This function is used internally when hotplugging drives." }; longdesc = "\ This function is used internally when hotplugging drives." }; + { defaults with + name = "mktemp"; + style = RString "path", [Pathname "tmpl"], [OString "suffix"]; + proc_nr = Some 373; + tests = [ + InitScratchFS, Always, TestRun ( + [["mkdir"; "/mktemp"]; + ["mktemp"; "/mktemp/tmpXXXXXX"; "NOARG"]; + ["mktemp"; "/mktemp/tmpXXXXXX"; "suff"]]) + ]; + shortdesc = "create a temporary file"; + longdesc = "\ +This command creates a temporary file. The +C<tmpl> parameter should be a full pathname for the +temporary directory name with the final six characters being +\"XXXXXX\". + +For example: \"/tmp/myprogXXXXXX\" or \"/Temp/myprogXXXXXX\", +the second one being suitable for Windows filesystems. + +The name of the temporary file that was created +is returned. + +The temporary file is created with mode 0600 +and is owned by root. + +The caller is responsible for deleting the temporary +file after use. + +If the optional C<suffix> parameter is given, then the suffix +(eg. C<.txt>) is appended to the temporary name. + +See also: C<guestfs_mkdtemp>." }; + ] (* Non-API meta-commands available only in guestfish. |