Subversion Repositories Kolibri OS

Rev

Rev 711 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 711 Rev 727
Line 66... Line 66...
66
    int prev_is_slash=0;
66
    int prev_is_slash=0;
67
    int len=0, depth=0, i;
67
    int len=0, depth=0, i;
68
    char* buff;
68
    char* buff;
69
    char c;
69
    char c;
Line -... Line 70...
-
 
70
 
-
 
71
 
-
 
72
    buff = (char*)lib_malloc(strlen(path)+2);
-
 
73
    strcpy(buff, path);
70
    
74
 
71
    if(*path == '/')
75
    if(*path == '/')
72
    {
76
    {
73
      buff = (char*)lib_malloc(strlen(path)+1);
77
      buff = (char*)lib_malloc(strlen(path)+1);
74
      buff[0] = '\0';
78
      buff[0] = '\0';
Line 125... Line 129...
125
          buff[len++] = c;
129
          buff[len++] = c;
126
          continue;
130
          continue;
127
        };
131
        };
128
    };
132
    };
129
    buff[len]= '\0';
133
    buff[len]= '\0';
-
 
134
    
130
    return buff;
135
    return buff;
131
};
136
};
Line 132... Line 137...
132
 
137
 
Line 169... Line 174...
169
  char *path;
174
  char *path;
170
  int err;
175
  int err;
Line 171... Line 176...
171
  
176
  
Line 172... Line 177...
172
  path = getfullpath(name);
177
  path = getfullpath(name);
-
 
178
 
-
 
179
  err=get_fileinfo(path,&info);
173
  
180
  
-
 
181
  if( mode & O_EXCL && mode & O_CREAT )
-
 
182
  {
174
  if(err=get_fileinfo(path,&info))
183
     if( !err)
-
 
184
     { 
-
 
185
       __set_errno( EEXIST );
-
 
186
       return (HANDLE)-1;
Line -... Line 187...
-
 
187
     };  
-
 
188
  } 
175
  {
189
 
176
//    printf("failed getfileinfo %s\n\r", path);
190
  if(err)
Line 177... Line 191...
177
      
191
  {
178
    if(mode & O_CREAT)
192
    if(mode & O_CREAT)
179
      err=create_file(path);
193
      err=create_file(path);
180
      
194
      
181
    if(err)
195
    if(err)
182
    {        
196
    {        
-
 
197
      lib_free(path); 
-
 
198
      return (HANDLE)-1;
Line 183... Line 199...
183
      lib_free(path); 
199
    };
-
 
200
  };
184
      return (HANDLE)-1;
201
  if( mode & O_TRUNC )
185
    };
202
    set_file_size(path, 0);
186
  };
203
      
Line 187... Line 204...
187
  
204
  if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) )))
188
  if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) )))
205
  {
Line 209... Line 226...
209
    if( hid == -1 )
226
    if( hid == -1 )
210
     {
227
     {
211
        return( -1 );
228
        return( -1 );
212
    }
229
    }
Line 213... Line 230...
213
 
230
 
214
    rwmode = mode;
-
 
Line 215... Line 231...
215
 
231
    rwmode = mode & ( O_RDONLY | O_WRONLY | O_RDWR | O_NOINHERIT );
Line 216... Line 232...
216
 
232
 
Line 223... Line 239...
223
      __freePOSIXHandle( hid );
239
      __freePOSIXHandle( hid );
224
      return( -1 ); //error
240
      return( -1 ); //error
225
    }
241
    }
Line 226... Line 242...
226
 
242
 
-
 
243
// Now use the slot we got.
227
// Now use the slot we got.
244
 
Line 228... Line 245...
228
    __setOSHandle( hid, handle );   // JBS 99/11/01
245
    __setOSHandle( hid, handle );   // JBS 99/11/01
Line 229... Line -...
229
 
-
 
230
    iomode_flags = 0;
246
 
231
 
247
    iomode_flags = 0;
232
 
248
 
233
    if( rwmode == O_RDWR )       iomode_flags |= _READ | _WRITE;
249
    if( rwmode == O_RDWR )       iomode_flags |= _READ | _WRITE;
234
    else if( rwmode == O_RDONLY) iomode_flags |= _READ;
250
    else if( rwmode == O_RDONLY) iomode_flags |= _READ;