Changeset 3279

Show
Ignore:
Timestamp:
04/19/08 16:10:34 (6 months ago)
Author:
dgollub
Message:

Introduces file helper functions for testing. This should replace ugly
system() calls to improve the portability of the testsuite.

osync_bool osync_testing_file_exists(const char *file)
osync_bool osync_testing_file_remove(const char *file)
osync_bool osync_testing_file_chmod(const char *file, int mode)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tests/support.c

    r3237 r3279  
    592592} 
    593593 
     594/*! @brief Check if file or directory exists. No check for regular file!  
     595 *  
     596 * @param file filename or fullpath of file/directory  
     597 * @returns TRUE if exists, FALSE otherwise 
     598 *  
     599 */ 
     600osync_bool osync_testing_file_exists(const char *file) 
     601{ 
     602        return g_file_test(file, G_FILE_TEST_EXISTS); 
     603} 
     604 
     605/*! @brief Removes files and directories  
     606 *  
     607 * @param file filename or fullpath of file/directory  
     608 * @returns TRUE on success, FALSE otherwise 
     609 *  
     610 */ 
     611osync_bool osync_testing_file_remove(const char *file) 
     612{ 
     613        return g_remove(file); 
     614} 
     615 
     616/*! @brief Modifies permission of file - like chmod()  
     617 *  
     618 * @param file filename or fullpath of file  
     619 * @param mode the permission mode like chmod() 
     620 * @returns TRUE on success, FALSE otherwise 
     621 *  
     622 */ 
     623osync_bool osync_testing_file_chmod(const char *file, int mode) 
     624{ 
     625        /* GLib 2.16.3 Note:  
     626           "[...] Software that needs to manage file  
     627           permissions on Windows exactly should use the Win32 API." 
     628        TODO: Do we have to care about this on Windows?! */ 
     629        return g_chmod(file, mode); 
     630} 
  • trunk/tests/support.h

    r3209 r3279  
    8787void conflict_handler_delay(OSyncEngine *engine, OSyncMappingEngine *mapping, void *user_data); 
    8888 
     89/* File testing helper */ 
     90osync_bool osync_testing_file_exists(const char *file); 
     91osync_bool osync_testing_file_remove(const char *file); 
     92osync_bool osync_testing_file_chmod(const char *file, int mode); 
    8993