Subversion Repositories Kolibri OS

Rev

Rev 548 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 548 Rev 550
Line 65... Line 65...
65
    DWORD    size;
65
    DWORD    size;
66
    DWORD    size_high; 
66
    DWORD    size_high; 
67
} FILEINFO;
67
} FILEINFO;
Line 68... Line 68...
68
 
68
 
-
 
69
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
Line 69... Line 70...
69
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
70
int _stdcall create_file(const char *name);
70
 
71
 
71
 
72
 
72
typedef struct 
73
typedef struct 
73
{
74
{
Line 74... Line 75...
74
  char     *name;
75
  char     *name;
75
  unsigned int offset;
76
  unsigned int offset;
76
}__file_handle;
77
}__file_handle;
77
 
78
 
78
 
79
 
79
static char* getfullpath(const char* path)
80
char* getfullpath(const char* path)
Line 175... Line 176...
175
  
176
  
Line 176... Line 177...
176
  return retval;
177
  return retval;
Line 177... Line -...
177
 
-
 
178
}
178
 
179
 
179
}
180
 
180
 
181
static HANDLE __createFileHandle(const CHAR_TYPE *name)
181
static HANDLE __openFileHandle(const CHAR_TYPE *name, int mode)
182
{
182
{
-
 
183
  FILEINFO info;
Line 183... Line 184...
183
  FILEINFO info;
184
  __file_handle *handle;
Line 184... Line 185...
184
  __file_handle *handle;
185
  char *path;
185
  char *path;
186
  int err;
186
 
187
  
-
 
188
  path = getfullpath(name);
-
 
189
  
-
 
190
  if(err=get_fileinfo(path,&info))
-
 
191
  {
-
 
192
//    printf("failed getfileinfo %s\n\r", path);
-
 
193
      
187
  path = getfullpath(name);
194
    if(mode & O_CREAT)
188
  
195
      err=create_file(path);
189
  if(get_fileinfo(path,&info))
196
      
-
 
197
    if(err)
Line 190... Line 198...
190
  {
198
    {        
191
//    printf("failed getfileinfo %s\n\r", path);  
199
      lib_free(path); 
192
    lib_free(path); 
200
      return (HANDLE)-1;
193
    return (HANDLE)-1;
201
    };
Line 203... Line 211...
203
 
211
 
204
  return (HANDLE)handle;
212
  return (HANDLE)handle;
Line 205... Line -...
205
};    
-
 
206
 
213
};    
207
 
214
 
208
 
215
 
209
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
216
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
210
{
217
{
Line 223... Line 230...
223
    rwmode = mode;
230
    rwmode = mode;
Line 224... Line 231...
224
 
231
 
Line 225... Line 232...
225
 
232
 
Line 226... Line 233...
226
    /*** Open the file ***/
233
    /*** Open the file ***/
227
        
234
        
228
    handle = __createFileHandle( name);
-
 
229
    
-
 
230
    if( handle==(HANDLE)-1 )
-
 
231
    {
-
 
232
 
-
 
233
      printf("handle = -1 \n\r");
-
 
234
        
-
 
235
      if( mode&O_CREAT )
-
 
236
      {
-
 
237
//             handle = CreateFileA( name, desired_access,
-
 
238
//                                   share_mode, NULL, create_disp,
-
 
239
//                                    fileattr, NULL );
235
    handle = __openFileHandle( name, mode);
240
      }
236
    
241
      if( handle == (HANDLE)-1 )
237
    if( handle==(HANDLE)-1 )
242
      {
-
 
Line 243... Line 238...
243
         __freePOSIXHandle( hid );
238
    {
244
         return( -1 ); //error
239
      __freePOSIXHandle( hid );
Line 245... Line 240...
245
      }
240
      return( -1 ); //error