"Fossies" - the Fresh Open Source Software Archive

Member "unrar/hardlinks.cpp" (4 May 2022, 1051 Bytes) of package /linux/misc/unrarsrc-6.1.7.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "hardlinks.cpp" see the Fossies "Dox" file reference documentation.

    1 bool ExtractHardlink(CommandData *Cmd,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
    2 {
    3   SlashToNative(NameExisting,NameExisting,NameExistingSize); // Not needed for RAR 5.1+ archives.
    4 
    5   if (!FileExist(NameExisting))
    6   {
    7     uiMsg(UIERROR_HLINKCREATE,NameNew);
    8     uiMsg(UIERROR_NOLINKTARGET);
    9     ErrHandler.SetErrorCode(RARX_CREATE);
   10     return false;
   11   }
   12   CreatePath(NameNew,true,Cmd->DisableNames);
   13 
   14 #ifdef _WIN_ALL
   15   bool Success=CreateHardLink(NameNew,NameExisting,NULL)!=0;
   16   if (!Success)
   17   {
   18     uiMsg(UIERROR_HLINKCREATE,NameNew);
   19     ErrHandler.SysErrMsg();
   20     ErrHandler.SetErrorCode(RARX_CREATE);
   21   }
   22   return Success;
   23 #elif defined(_UNIX)
   24   char NameExistingA[NM],NameNewA[NM];
   25   WideToChar(NameExisting,NameExistingA,ASIZE(NameExistingA));
   26   WideToChar(NameNew,NameNewA,ASIZE(NameNewA));
   27   bool Success=link(NameExistingA,NameNewA)==0;
   28   if (!Success)
   29   {
   30     uiMsg(UIERROR_HLINKCREATE,NameNew);
   31     ErrHandler.SysErrMsg();
   32     ErrHandler.SetErrorCode(RARX_CREATE);
   33   }
   34   return Success;
   35 #else
   36   return false;
   37 #endif
   38 }
   39