summaryrefslogtreecommitdiff
path: root/src/lib/eio/eio_inline_helper.x
blob: af49646b72491a0837396ab85daec518926c44b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* EIO - EFL data type library
 * Copyright (C) 2010 Enlightenment Developers:
 *           Cedric Bail <cedric.bail@free.fr>
 *           Vincent "caro" Torri  <vtorri at univ-evry dot fr>
 *	     Stephen "okra" Houston <unixtitan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library;
 * if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef EIO_INLINE_HELPER_H__
# define EIO_INLINE_HELPER_H__

/**
 * @addtogroup Eio_Helper
 *
 * @{
 */

/**
 * @brief Return last acces time to a file
 * @param stat The stat buffer as given by eio_file_stat callback.
 * @return last access time.
 *
 * This function return the st_atime field, last acces time, as double like all EFL time call.
 */
static inline double
eio_file_atime(const Eina_Stat *st)
{
   if (!st) return 0.0;
   return (double) st->atime;
}

/**
 * @brief Return last modification time of a file
 * @param stat The stat buffer as given by eio_file_stat callback.
 * @return last modification time.
 *
 * This function return the st_mtime field, last modification time, as double like all EFL time call.
 */
static inline double
eio_file_mtime(const Eina_Stat *st)
{
   if (!st) return 0.0;
   return (double) st->mtime;
}

/**
 * @brief Return file length.
 * @param stat The stat buffer as given by eio_file_stat callback.
 * @return the length of a file.
 *
 * This function is just an accessor to st_size and return the file length.
 */
static inline long long
eio_file_size(const Eina_Stat *st)
{
   if (!st) return 0;
   return st->size;
}

/**
 * @brief Return if path is a directory.
 * @param stat The stat buffer as given by eio_file_stat callback.
 * @return EINA_TRUE if the path is a directory.
 *
 * This function tell you if the stated path is a directory or not.
 */
static inline Eina_Bool
eio_file_is_dir(const Eina_Stat *st)
{
   if (!st) return EINA_FALSE;
   return (S_ISDIR(st->mode)) ? EINA_TRUE : EINA_FALSE;
}

/**
 * @brief Return if path is a length.
 * @param stat The stat buffer as given by eio_file_stat callback.
 * @return EINA_TRUE if the path is a length.
 *
 * This function tell you if the stated path is a length or not.
 */
static inline Eina_Bool
eio_file_is_lnk(const Eina_Stat *st)
{
   if (!st) return EINA_FALSE;
   return (S_ISLNK(st->mode)) ? EINA_TRUE : EINA_FALSE;
}

/**
 * @}
 */

#endif