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
|
/* Tux Commander VFS: VFS utilities
* Copyright (C) 2007-2009 Tomas Bzatek <tbzatek@users.sourceforge.net>
* Check for updates on tuxcmd.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <glib.h>
#include "strutils.h"
#include "logutils.h"
#include "tuxcmd-vfs.h"
void
copy_vfs_item (struct TVFSItem *src, struct TVFSItem *dst)
{
memcpy (dst, src, sizeof (struct TVFSItem));
dst->FName = g_strdup (src->FName);
dst->FDisplayName = g_strdup (src->FDisplayName);
dst->sLinkTo = g_strdup (src->sLinkTo);
}
void
free_vfs_item (struct TVFSItem *item)
{
if (item) {
g_free (item->FName);
g_free (item->FDisplayName);
g_free (item->sLinkTo);
g_free (item);
}
}
/* -------------------------------------------------------------------------------------- */
struct TVFSItem *
create_placeholder_item (const char *name, enum TVFSItemType item_type)
{
struct TVFSItem *data;
data = g_malloc0 (sizeof (struct TVFSItem));
data->FName = g_strdup (name);
data->FDisplayName = g_strdup (name);
data->ItemType = item_type;
data->iMode = S_IRWXO + S_IRWXG + S_IRWXU;
data->IsLink = FALSE;
data->iUID = geteuid ();
data->iGID = getegid ();
data->m_time = time (NULL);
data->c_time = data->m_time;
data->a_time = data->m_time;
data->iSize = 0;
data->iPackedSize = -1;
return data;
}
/* -------------------------------------------------------------------------------------- */
gboolean
compare_two_same_files (const char *path1, const char *path2)
{
char *f1, *f2;
gboolean b;
f1 = exclude_trailing_path_sep (path1);
f2 = exclude_trailing_path_sep (path2);
b = (g_strcmp0 (f1, f2) == 0);
g_free (f1);
g_free (f2);
return b;
}
|