summaryrefslogtreecommitdiff
path: root/testautomation/global/tools/includes/required/t_files.inc
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2009-03-16 15:55:50 +0000
committerVladimir Glazounov <vg@openoffice.org>2009-03-16 15:55:50 +0000
commitd398d7b03cdd019e2dd6eae41463418d01be8320 (patch)
treeb2b057c66a09761cb2eabffbb6963e9a59edc969 /testautomation/global/tools/includes/required/t_files.inc
parent566d54fc21efaa8be2b3044c8730a125eafdd00d (diff)
CWS-TOOLING: integrate CWS automation310c_DEV300
2009-03-16 13:33:04 +0100 jsk r269530 : #i100184 2009-03-16 13:31:17 +0100 jsk r269528 : #i100232#
Diffstat (limited to 'testautomation/global/tools/includes/required/t_files.inc')
-rwxr-xr-xtestautomation/global/tools/includes/required/t_files.inc89
1 files changed, 89 insertions, 0 deletions
diff --git a/testautomation/global/tools/includes/required/t_files.inc b/testautomation/global/tools/includes/required/t_files.inc
index 36b9f5aae7b1..cc20a48fe1c7 100755
--- a/testautomation/global/tools/includes/required/t_files.inc
+++ b/testautomation/global/tools/includes/required/t_files.inc
@@ -633,6 +633,95 @@ end function
'
'-------------------------------------------------------------------------------
'
+function hDeleteFile( cFileOrig as string ) as boolean
+
+ const CFN = "global::tools::includes::required::t_files.inc::hDeleteFile():"
+ dim cHome as string
+ cHome = gOfficePath & "user"
+ cHome = convertpath( cHome )
+ dim cFile as string
+ cFile = convertpath( cFileOrig )
+
+ '///<h3>Delete a file</h3>
+ '///<i>In many cases it is a good idea to use this function outside the testcase.<br>
+ '///+ You should always evaluate the returncode</i><br>
+ '///<u>Input</u>:
+ '///<ol>
+ '///+<li>Filename (string)</li>
+ '///<ul>
+ '///+<li>The function converts the path to system specific syntax (convertpath)
+ '///+ but does <b>not</b> modify the input parameter</li>
+ '///</ul>
+ '///</ol>
+ '///<u>Returns</u>:
+ '///<ol>
+ '///+<li>Errorstatus (boolean)</li>
+ '///<ul>
+ '///+<li>TRUE: File was deleted/does not exist</li>
+ '///+<li>FALSE: File could not be deleted/any other error</li>
+ '///</ul>
+ '///</ol>
+ '///<u>Description</u>:
+ '///<ul>
+
+ ' this function tries to delete a file and does some very basic error-
+ ' handling. Returns 'true' on success, only error while deleting returns
+ ' 'false', if the file does not exist, it is considered to be successfully
+ ' deleted.
+ ' i introduced this function due to a number of cases where deleting files
+ ' actually failed because of weird code or situations where the user lacks
+ ' accessrights to files are not handled at all.
+
+ '///+<li>We may never delete a file outside gOfficePath/user/work</li>
+ if ( instr( cFile , cHome ) = 0 ) then
+ qaerrorlog( CFN & "Trying to delete file outside (default)homedir -> forbidden" )
+ qaerrorlog( CFN & "Home: " & cHome )
+ qaerrorlog( CFN & "File: " & cFile )
+ hDeleteFile() = false
+ exit function
+ endif
+
+ cFile = convertpath( cFile )
+
+ '///+<li>Check that the file exists</li>
+ if ( FileExists( cFile ) ) then
+
+ '///+<li>Use kill to delete</li>
+ try
+
+ kill( cFile )
+
+ '///+<li>Verify that the file does not exist anymore</li>
+ if ( FileExists( cFile ) ) then
+ warnlog( CFN & "File was not deleted: " & cFile )
+ hDeleteFile() = false
+ else
+ if ( VERBOSE ) then printlog( CFN & "File successfully deleted: " & cFile )
+ hDeleteFile() = true
+ endif
+
+ catch
+
+ '///+<li>in very rare cases 'kill' fails and can be handled this way</li>
+ qaerrorlog( CFN & "Deleting file failed: " & cFile )
+ hDeleteFile() = false
+
+ endcatch
+
+ else
+
+ '///+<li>write some text to the log if the file does not exist</li>
+ printlog( CFN & "Nothing to do." )
+ hDeleteFile() = true
+
+ endif
+
+ '///</ul>
+
+end function
+'
+'-------------------------------------------------------------------------------
+'
function hFileOpen( cFile as string ) as boolean
dim sFile as string : sFile = convertToURL( convertpath( cFile ) )