Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (in-package :ftp-log)
- (ql:quickload :cl-ppcre)
- (ql:quickload :cl-strftime)
- (ql:quickload :file-attributes)
- (defun get-log-file-list (logd op)
- (with-open-file (logfile
- (format nil "~A~A-~A-ftp.log" logd op (cl-strftime:format-time nil "%d%m%Y"))
- :if-does-not-exist :create)
- (loop for line = (read-line logfile nil nil)
- while line
- collect (cl-ppcre:do-register-groups (fline)
- ("\\S+\\s(\\w+.+)" line) (return fline)))))
- (defun ftp-log (src fpattern logd op)
- (let ((ftp-dir-files (directory (format nil "~A~A" src fpattern))))
- (if (> (length ftp-dir-files) 0)
- (let ((loglist (get-log-file-list logd op)))
- (loop for file in ftp-dir-files
- do
- (if (not (member (format nil "~A.~A" (pathname-name file) (pathname-type file))
- loglist :test #'equal))
- (with-open-file (logfile
- (format nil "~A~A-~A-ftp.log"
- logd op (cl-strftime:format-time nil "%d%m%Y"))
- :direction :output :if-does-not-exist :create :if-exists :append)
- (write-line (format nil "~A ~A.~A"
- (cl-strftime:format-time nil :rfc-3339 (org.shirakumo.file-attributes:modification-time logfile))
- (pathname-name file) (pathname-type file) ) logfile))
- nil))
- nil))))
- (defun main ()
- (ftp-log "/data/genoa/upload/mp4/" "*.wav" "./" "genoa"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement