Item1441: No way to open a handle on an attachment from Func
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
This can be very important when you are working with very large attachments, where reading the entire attachment is just stupid. Two types of open are require, open-read and open-write (optional append). Solution:
openAttachment($web, $topic, $attachment, $mode) -> $fh
Opens the given attachment. The attachment must exist. The attachment will be locked for other changes as long as the file handle is open. Modes '>', '<' and '>>' should be supported.
Errors will be signalled by an
testAttachment(web, topic, attachment, mode)
Performs a type test on the given attachment.
$test - the test to perform
The return value is the value that would be returned by the standard perl file operations, as indicated by
- r File is readable by current user (tests Foswiki permissions, not file permissions)
- w File is writable by current user (tests Foswiki permissions, not file permissions)
- e File exists.
- z File has zero size.
- s File has nonzero size (returns size).
- T File is an ASCII text file (heuristic guess).
- B File is a "binary" file (opposite of T).
- M Last modification time (epoch seconds).
- A Last access time (epoch seconds).
Note that all these types should behave as the equivalent standard perl operator behaves, except
which are independent of the script start time (see
perldoc -f -X
for more information)
Ended up adding
. Meta is published, and the function site better there anyway. Persuaded by Sven to use a mode parameter rather than having two functions.
- 15 Apr 2009