OpenClonk
group-handle.cpp
Go to the documentation of this file.
1 /*
2  * mape - C4 Landscape.txt editor
3  *
4  * Copyright (c) 2005-2009, Armin Burgmeier
5  *
6  * Distributed under the terms of the ISC license; see accompanying file
7  * "COPYING" for details.
8  *
9  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10  * See accompanying file "TRADEMARK" for details.
11  *
12  * To redistribute this file separately, substitute the full license texts
13  * for the above references.
14  */
15 
16 #include "C4Include.h"
17 #include "c4group/C4Group.h"
19 
20 #define GROUP_TO_HANDLE(group) (reinterpret_cast<C4GroupHandle*>(group))
21 #define HANDLE_TO_GROUP(handle) (reinterpret_cast<C4Group*>(handle))
22 
23 extern "C" {
24 
26 {
27  return GROUP_TO_HANDLE(new C4Group);
28 }
29 
31 {
32  delete HANDLE_TO_GROUP(handle);
33 }
34 
36 {
37  return HANDLE_TO_GROUP(handle)->GetError();
38 }
39 
40 gboolean c4_group_handle_open(C4GroupHandle* handle, const gchar* path, gboolean create)
41 {
42  return HANDLE_TO_GROUP(handle)->Open(path, create);
43 }
44 
45 gboolean c4_group_handle_open_as_child(C4GroupHandle* handle, C4GroupHandle* mother, const gchar* name, gboolean exclusive, gboolean create)
46 {
47  return HANDLE_TO_GROUP(handle)->OpenAsChild(HANDLE_TO_GROUP(mother),
48  name, exclusive, create);
49 }
50 
52 {
53  return HANDLE_TO_GROUP(handle)->GetName();
54 }
55 
57 {
58  StdStrBuf buf(HANDLE_TO_GROUP(handle)->GetFullName());
59  gchar* res = static_cast<gchar*>(g_malloc(buf.getSize()*sizeof(gchar)));
60  memcpy(res, buf.getData(), buf.getSize());
61  return res;
62 }
63 
65 {
66  HANDLE_TO_GROUP(handle)->ResetSearch();
67 }
68 
69 gboolean c4_group_handle_find_next_entry(C4GroupHandle* handle, const gchar* wildcard, gsize* size, gchar* filename, gboolean start_at_filename)
70 {
71  return HANDLE_TO_GROUP(handle)->FindNextEntry(wildcard, filename, size, start_at_filename);
72 }
73 
74 gboolean c4_group_handle_access_next_entry(C4GroupHandle* handle, const gchar* wildcard, gsize* size, gchar* filename, gboolean start_at_filename)
75 {
76  return HANDLE_TO_GROUP(handle)->AccessNextEntry(wildcard, size, filename, start_at_filename);
77 }
78 
79 gboolean c4_group_handle_access_entry(C4GroupHandle* handle, const gchar* wildcard, gsize* size, gchar* filename, gboolean needs_to_be_a_group)
80 {
81  return HANDLE_TO_GROUP(handle)->AccessEntry(wildcard, size, filename, needs_to_be_a_group);
82 }
83 
85 {
86  return HANDLE_TO_GROUP(handle)->AccessedEntrySize();
87 }
88 
89 gboolean c4_group_handle_read(C4GroupHandle* handle, gpointer buffer, gsize size)
90 {
91  return HANDLE_TO_GROUP(handle)->Read(buffer, size);
92 }
93 
95 {
96  C4Group *group = HANDLE_TO_GROUP(handle);
97  return group->IsOpen() && !group->IsPacked();
98 }
99 
100 } /* extern "C" */
bool IsPacked() const
Definition: C4Group.cpp:2541
bool IsOpen() const
Definition: C4Group.cpp:2373
size_t getSize() const
Definition: StdBuf.h:444
const char * getData() const
Definition: StdBuf.h:442
gboolean c4_group_handle_open_as_child(C4GroupHandle *handle, C4GroupHandle *mother, const gchar *name, gboolean exclusive, gboolean create)
#define GROUP_TO_HANDLE(group)
void c4_group_handle_reset_search(C4GroupHandle *handle)
void c4_group_handle_free(C4GroupHandle *handle)
C4GroupHandle * c4_group_handle_new(void)
gboolean c4_group_handle_access_next_entry(C4GroupHandle *handle, const gchar *wildcard, gsize *size, gchar *filename, gboolean start_at_filename)
gboolean c4_group_handle_is_folder(C4GroupHandle *handle)
const gchar * c4_group_handle_get_name(C4GroupHandle *handle)
const gchar * c4_group_handle_get_error(C4GroupHandle *handle)
gboolean c4_group_handle_access_entry(C4GroupHandle *handle, const gchar *wildcard, gsize *size, gchar *filename, gboolean needs_to_be_a_group)
#define HANDLE_TO_GROUP(handle)
gsize c4_group_handle_accessed_entry_size(C4GroupHandle *handle)
gboolean c4_group_handle_open(C4GroupHandle *handle, const gchar *path, gboolean create)
gboolean c4_group_handle_read(C4GroupHandle *handle, gpointer buffer, gsize size)
gboolean c4_group_handle_find_next_entry(C4GroupHandle *handle, const gchar *wildcard, gsize *size, gchar *filename, gboolean start_at_filename)
gchar * c4_group_handle_get_full_name(C4GroupHandle *handle)
typedefG_BEGIN_DECLS struct _C4GroupHandle C4GroupHandle
Definition: group-handle.h:23