Advertisement
symdrome

Untitled

Feb 29th, 2024
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.31 KB | None | 0 0
  1. (in-package :ftp-log)
  2.  
  3. (ql:quickload :cl-ppcre)
  4. (ql:quickload :cl-strftime)
  5. (ql:quickload :file-attributes)
  6.  
  7. (defun get-log-file-list (logd op)
  8.   (with-open-file (logfile
  9.            (format nil "~A~A-~A-ftp.log" logd op (cl-strftime:format-time nil "%d%m%Y"))
  10.            :if-does-not-exist :create)
  11.     (loop for line = (read-line logfile nil nil)
  12.       while line
  13.       collect (cl-ppcre:do-register-groups (fline)
  14.               ("\\S+\\s(\\w+.+)" line) (return fline)))))
  15.  
  16. (defun ftp-log (src fpattern logd op)
  17.   (let ((ftp-dir-files (directory (format nil "~A~A" src fpattern))))
  18.     (if (> (length ftp-dir-files) 0)
  19.     (let ((loglist (get-log-file-list logd op)))
  20.       (loop for file in ftp-dir-files
  21.         do
  22.            (if (not (member (format nil "~A.~A" (pathname-name file) (pathname-type file))
  23.                     loglist :test #'equal))
  24.                (with-open-file (logfile
  25.                     (format nil "~A~A-~A-ftp.log"
  26.                         logd op (cl-strftime:format-time nil "%d%m%Y"))
  27.                     :direction :output :if-does-not-exist :create :if-exists :append)
  28.              (write-line (format nil "~A ~A.~A"
  29.                          (cl-strftime:format-time nil :rfc-3339 (org.shirakumo.file-attributes:modification-time logfile))
  30.                          (pathname-name file) (pathname-type file) ) logfile))
  31.                nil))
  32.       nil))))
  33.  
  34. (defun main ()
  35.   (ftp-log "/data/genoa/upload/mp4/" "*.wav" "./" "genoa"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement