Subversion Repositories Kolibri OS

Rev

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

Rev 4921 Rev 9952
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (C) KolibriOS team 2004-2024. All rights reserved.
-
 
3
 * Distributed under terms of the GNU General Public License
-
 
4
*/
Line 1... Line 5...
1
#include 
5
 
2
#include 
6
#include 
3
#include 
7
#include 
4
#include 
8
#include 
5
#include "glue.h"
9
#include 
6
#include "io.h"
10
#include "glue.h"
Line 7... Line -...
7
 
-
 
8
 
11
#include "io.h"
9
_off_t
12
 
10
_DEFUN (lseek, (fd, pos, whence),
13
_off_t
11
     int fd _AND
14
_DEFUN (lseek, (fd, pos, whence),
12
     _off_t pos _AND
15
     int fd _AND
13
     int whence)
-
 
14
 
16
     _off_t pos _AND
15
{
17
     int whence)
16
    fileinfo_t  info;
18
{
17
    __io_handle *ioh;
19
    ksys_file_info_t info;
Line 18... Line 20...
18
    _off_t ret;
20
    __io_handle *ioh;
19
 
21
    _off_t ret;
20
    if( (fd < 0) || (fd >=64) )
22
 
21
    {
23
    if ((fd < 0) || (fd >=64))
22
        errno = EBADF;
24
    {
Line 23... Line 25...
23
        return (-1);
25
        errno = EBADF;
Line 24... Line 26...
24
    };
26
        return (-1);
25
 
27
    }
Line 34... Line 36...
34
            ret = ioh->offset + pos;
36
        case SEEK_CUR:
35
            break;
37
            ret = ioh->offset + pos;
36
        case SEEK_END:
38
            break;
37
        {
39
        case SEEK_END:
38
            get_fileinfo(ioh->name, &info);
40
        {
39
            ret = pos + info.size;
41
            _ksys_file_info(ioh->name, &info);
40
            break;
42
            ret = pos + info.size;
41
        }
43
            break;
42
        default:
44
        }
43
            errno = EINVAL;
45
        default:
44
            return (-1);
46
            errno = EINVAL;
45
    };
47
            return -1;
46
 
48
    }
Line 47... Line 49...
47
    ioh->offset = ret;
49
 
Line 48... Line 50...
48
 
50
    ioh->offset = ret;
49
    return( ret );
51