Move a single file from the source filepath to the target filepath. This is functionally similar to the UNIX mv command or the C library function rename except that overwriting a file is not permitted.

Return TypeFunction nameArguments
hzEcodeFilemove(hzString&,hzString&,)

Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp

Function Logic:

0:START 1:unknown 2:Return E_ARGUMENT 3:unknown 4:Return E_NOTFOUND 5:unknown 6:Return E_TYPE 7:unknown 8:unknown 9:Return E_TYPE 10:Return E_DUPLICATE 11:unknown 12:Return E_WRITEFAIL 13:Return E_OK

Function body:

hzEcode Filemove (hzString& src)hzString& tgt, 
{
   //  Category: Directory
   //  
   //  Move a single file from the source filepath to the target filepath. This is functionally similar to the UNIX mv command or the C library function rename
   //  except that overwriting a file is not permitted.
   //  
   //  Arguments: 1) source The source filepath
   //     2) target The target filepath
   //  
   //  Returns: E_ARGUMENT If either the source or the target is not supplied
   //     E_NOTFOUND If the source file does not exist
   //     E_DUPLICATE If the target file does exist
   //     E_TYPE  If either the source or target is a directory
   //     E_WRITEFAIL If the rename operation failed
   //     E_OK  If the file was moved
   _hzfunc(__func__) ;
   FSTAT       fs ;            //  File status
   if (!tgt || !src)
       return E_ARGUMENT ;
   if (lstat(src, &fs) < 0)
       return E_NOTFOUND ;
   if (S_ISDIR(fs.st_mode))
       return E_TYPE ;
   //  Check if target exists
   if (lstat(tgt, &fs) == 0)
   {
       if (S_ISDIR(fs.st_mode))
           return E_TYPE ;
       return E_DUPLICATE ;
   }
   if (rename(*src, *tgt) < 0)
       return E_WRITEFAIL ;
   return E_OK ;
}