KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically retrieving the backup destination folder
PRODUCT: 4D | VERSION: 2004.3 | PLATFORM: Mac & Win
Published On: January 2, 2006
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

The backup destination folder is stored in the Backup.xml file. You can programmatically get this information using 4D XML commands. Below is an sample code that does this:

 `Method: CheckBackupDestinationFolder
 ` Description: It will check and return the backup destination folder.
C_TEXT(Path_Structure;$0)
C_TEXT(Path_Prefs;Path_Structure;Path_BackupXML)
C_TEXT($elementRef1;$elementRef2)
C_INTEGER($separator;$StrPtr)
C_INTEGER($myPlatform;$mySystem;$myMachine)

PLATFORM PROPERTIES($myPlatform;$mySystem;$myMachine)
If ($myPlatform=Windows ) ` check if platform is Windows or Mac
 $separator:=Ascii("\\")
Else
 $separator:=Ascii(":")
End if

Path_Structure:=Structure file ` get the pathname of Structure file.
$StrPtr:=Length(Path_Structure) ` get length of string
While (Path_Structure[[$StrPtr]]#Char($separator)) ` starting from the end of string, find first occurence of the separator
 $StrPtr:=$StrPtr-1
End while
$var1:=Substring(Path_Structure;1;$StrPtr) ` extract path to preferences
Path_Prefs:=$var1+"Preferences"
Path_BackupXML:=Path_Prefs+Char($separator)+"Backup"+Char($separator)+"Backup.xml" ` path to backup.xml file
$ref1:=DOM Parse XML source(Path_BackupXML)
$elementRef1:=DOM Find XML element($ref1;"/Preferences4D/Backup/Settings/General")
$elementRef2:=DOM Find XML element($elementRef1;"/General/DestinationFolder") ` find Destination folder element
DOM GET XML ELEMENT VALUE($elementRef2;value) ` get element value for destination folder
DOM CLOSE XML($ref1)

$0:=value ` return destination folder of backup.