~ubuntu-branches/ubuntu/utopic/unrar-nonfree/utopic-updates

« back to all changes in this revision

Viewing changes to filcreat.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Meredith
  • Date: 2006-11-01 11:58:20 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061101115820-41wn9un5v4m9r3jh
Tags: 1:3.6.8-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
#ifdef  _WIN_32
63
63
        File SrcFile;
64
64
        SrcFile.SetHandleType(FILE_HANDLESTD);
65
 
        int Size=SrcFile.Read(NewName,NM);
 
65
        int Size=SrcFile.Read(NewName,sizeof(NewName)-1);
66
66
        NewName[Size]=0;
67
67
        OemToChar(NewName,NewName);
68
68
#else
80
80
      if (Choice==6)
81
81
        ErrHandler.Exit(USER_BREAK);
82
82
    }
 
83
    if (Mode==OVERWRITE_AUTORENAME)
 
84
    {
 
85
      if (GetAutoRenamedName(Name))
 
86
      {
 
87
        if (NameW!=NULL)
 
88
          *NameW=0;
 
89
      }
 
90
      else
 
91
        Mode=OVERWRITE_ASK;
 
92
      continue;
 
93
    }
83
94
  }
84
95
  if (NewFile!=NULL && NewFile->Create(Name,NameW))
85
96
    return(true);
89
100
}
90
101
 
91
102
 
 
103
bool GetAutoRenamedName(char *Name)
 
104
{
 
105
  char NewName[NM];
 
106
 
 
107
  if (strlen(Name)>sizeof(NewName)-10)
 
108
    return(false);
 
109
  char *Ext=GetExt(Name);
 
110
  if (Ext==NULL)
 
111
    Ext=Name+strlen(Name);
 
112
  for (int FileVer=1;;FileVer++)
 
113
  {
 
114
    sprintf(NewName,"%.*s(%d)%s",Ext-Name,Name,FileVer,Ext);
 
115
    if (!FileExist(NewName))
 
116
    {
 
117
      strcpy(Name,NewName);
 
118
      break;
 
119
    }
 
120
    if (FileVer>=1000000)
 
121
      return(false);
 
122
  }
 
123
  return(true);
 
124
}
 
125
 
 
126
 
92
127
#if defined(_WIN_32) && !defined(_WIN_CE)
93
128
bool UpdateExistingShortName(char *Name,wchar *NameW)
94
129
{