Skip to content

Commit

Permalink
REDCAP: Added redcap-get-filename for getting file name from header o…
Browse files Browse the repository at this point in the history
…f exported file.
  • Loading branch information
ddunsmuir committed Jun 19, 2015
1 parent acb7635 commit 1292f41
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions modules/redcap/redcap.scm
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
)
)

(define (redcap-get-filename header)
;; Get index of name=" which occurs before file name in the header
(let* ((nameindex1 (string-contains header "name=\""))
;; Get part of header string after the above string
(subheader (substring header (+ nameindex1 6) (string-length header)))
;; Get index of next quotation marks
(nameindex2 (if nameindex1 (string-contains subheader "\"") #f)))
;; Return the name of the file
(if (and nameindex1 nameindex2)
(substring subheader 0 nameindex2)
#f))
)

(define (redcap:arg k args def)
(let loop ((as args))
(if (fx= (length as) 0)
Expand Down

0 comments on commit 1292f41

Please sign in to comment.