~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjlib/src/pj/file_access_unistd.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: file_access_unistd.c 3553 2011-05-05 06:14:19Z nanang $ */
2
 
/*
3
 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
 
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
 */
20
 
#include <pj/file_access.h>
21
 
#include <pj/assert.h>
22
 
#include <pj/errno.h>
23
 
 
24
 
#include <sys/types.h>
25
 
#include <sys/stat.h>
26
 
#include <unistd.h>
27
 
#include <stdio.h>      /* rename() */
28
 
#include <errno.h>
29
 
 
30
 
/*
31
 
 * pj_file_exists()
32
 
 */
33
 
PJ_DEF(pj_bool_t) pj_file_exists(const char *filename)
34
 
{
35
 
    struct stat buf;
36
 
 
37
 
    PJ_ASSERT_RETURN(filename, 0);
38
 
 
39
 
    if (stat(filename, &buf) != 0)
40
 
        return 0;
41
 
 
42
 
    return PJ_TRUE;
43
 
}
44
 
 
45
 
 
46
 
/*
47
 
 * pj_file_size()
48
 
 */
49
 
PJ_DEF(pj_off_t) pj_file_size(const char *filename)
50
 
{
51
 
    struct stat buf;
52
 
 
53
 
    PJ_ASSERT_RETURN(filename, -1);
54
 
 
55
 
    if (stat(filename, &buf) != 0)
56
 
        return -1;
57
 
 
58
 
    return buf.st_size;
59
 
}
60
 
 
61
 
 
62
 
/*
63
 
 * pj_file_delete()
64
 
 */
65
 
PJ_DEF(pj_status_t) pj_file_delete(const char *filename)
66
 
{
67
 
    PJ_ASSERT_RETURN(filename, PJ_EINVAL);
68
 
 
69
 
    if (unlink(filename)!=0) {
70
 
        return PJ_RETURN_OS_ERROR(errno);
71
 
    }
72
 
    return PJ_SUCCESS;
73
 
}
74
 
 
75
 
 
76
 
/*
77
 
 * pj_file_move()
78
 
 */
79
 
PJ_DEF(pj_status_t) pj_file_move( const char *oldname, const char *newname)
80
 
{
81
 
    PJ_ASSERT_RETURN(oldname && newname, PJ_EINVAL);
82
 
 
83
 
    if (rename(oldname, newname) != 0) {
84
 
        return PJ_RETURN_OS_ERROR(errno);
85
 
    }
86
 
    return PJ_SUCCESS;
87
 
}
88
 
 
89
 
 
90
 
/*
91
 
 * pj_file_getstat()
92
 
 */
93
 
PJ_DEF(pj_status_t) pj_file_getstat(const char *filename,
94
 
                                    pj_file_stat *statbuf)
95
 
{
96
 
    struct stat buf;
97
 
 
98
 
    PJ_ASSERT_RETURN(filename && statbuf, PJ_EINVAL);
99
 
 
100
 
    if (stat(filename, &buf) != 0) {
101
 
        return PJ_RETURN_OS_ERROR(errno);
102
 
    }
103
 
 
104
 
    statbuf->size = buf.st_size;
105
 
    statbuf->ctime.sec = buf.st_ctime;
106
 
    statbuf->ctime.msec = 0;
107
 
    statbuf->mtime.sec = buf.st_mtime;
108
 
    statbuf->mtime.msec = 0;
109
 
    statbuf->atime.sec = buf.st_atime;
110
 
    statbuf->atime.msec = 0;
111
 
 
112
 
    return PJ_SUCCESS;
113
 
}