View Single Post
  #4  
Old 05-08-2018, 08:56 AM
gmatelich's Avatar
gmatelich gmatelich is offline
Registered User
 
Join Date: Oct 2002
Location: Bellevue, WA, USA
Posts: 396
Re: Super Fast Autosave

Getting closer I think:

Code:
(in-package :valve)
(use-package :oli)
(sd-display-alert "Loading Autosave" :icon :info :auto-close-time 5)
(defvar *AutoSaveIncrement* 1)																							;Loop counter
(defvar *AutoSaveNumberOfIncrements* 2)																					;How many backups do you want? 
(defvar *AutoSaveBaseLocation* "Directory")																			;Establish autosave location variable

(unless (sd-directory-p (format nil "~AAutosave" (sd-inq-temp-dir)))													;Check if an autosave directory exists in the user's temp directoy
  (sd-make-directory (format nil "~AAutosave" (sd-inq-temp-dir)))														;Make Autosave directory
)

(defun AutoSaveBaseline
;  (oli::sd-display-alert (+ (oli::sd-inq-temp-dir) "Autosave/" (oli::get-universal-time)))	  
  (setf *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))						;Establish autosave location
  (sd-make-directory *AutoSaveBaseLocation*)																			;Create autosave location
  (sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 5)												;Popup toast warning user what's up
  (sd-with-current-working-directory AutoSaveBaseLocation																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY complete)									;Save all items using .sd format 
    (sd-display-alert (+ "Autosaved to " *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)						;Popup toast showing location saved to
    (sd-copy-file *AutoSaveBaseLocation* (+ *AutoSaveBaseLocation* "BaseCopy"))											;Capture fallback copy of baseline save
; actually I think I want something like this: (oli:sd-sys-background-job "xcopy C:\\Users\\gregm\\Documents\\AutosaveTest\\20180412a %temp%\\20180412ab\\")
  )
)
 
(defun AutoSaveIncremental
  (oli:sd-display-alert "Beginning Autosave" :icon :info :auto-close-time 1)											;Popup toast warning user what's up
  (sd-with-current-working-directory *AutoSaveBaseLocation*																;Remember CWD, change dir, run these things, revert to CWD
    (save_sd_modified :OVERWRITE :all_at_top :TOP_LEVEL_INSTANCE_FILES :YES :DIRECTORY *AutoSaveBaseLocation* complete) ;Save all modified items - super fast 
    (oli:sd-display-alert (+ "AutoSave to " *AutoSaveBaseLocation*) :icon :info :auto-close-time 5)						;Popup toast showing location saved to
    (oli:sd-copy-file *AutoSaveBaseLocation* (+ *AutoSaveBaseLocation* "_" AutoSaveIncrement))							;Capture fallback copy of incremental save
  )	
  (if (= *AutoSaveIncrement* *AutoSaveNumberOfIncrements*)																;Loop to capture fallback increments
    (defvar *AutoSaveIncrement* 1)																						;Reset to 1
	(+ *AutoSaveIncrement* 1)																							;Increment by 1
  )	
)

(sd-display-alert "Done loading Autosave" :icon :info :auto-close-time 5)
I'm not sure why I'm getting an error about not being a symbol
Code:
(setf *AutoSaveBaseLocation* (format nil "~AAutosave/~A" (sd-inq-temp-dir) (get-universal-time)))
Reply With Quote