Subversion Repositories Kolibri OS

Rev

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

Rev 9952 Rev 9970
Line 4... Line 4...
4
#include 
4
#include 
5
#include 
5
#include 
6
#include 
6
#include 
7
#include 
7
#include 
8
#include 
8
#include 
9
#ifndef _KOLIBRI
-
 
10
#include 
9
#include 
11
#endif
-
 
12
#include 
10
#include 
13
#ifndef __MINGW32__
11
#ifndef __MINGW32__
14
#include 
12
#include 
15
#include 
13
#include 
16
#include 
14
#include 
Line 39... Line 37...
39
#if MAX_PATH < PATH_MAX
37
#if MAX_PATH < PATH_MAX
40
#error MAX_PATH < PATH_MAX. You should use MAX_PATH.
38
#error MAX_PATH < PATH_MAX. You should use MAX_PATH.
41
#endif
39
#endif
42
#endif
40
#endif
Line 43... Line -...
43
 
-
 
44
#ifdef _KOLIBRI
-
 
45
char* kos_dgen_userdir = "/tmp0/1";
-
 
46
 
-
 
47
#endif
-
 
48
 
41
 
49
static const char *fopen_mode(unsigned int mode)
42
static const char *fopen_mode(unsigned int mode)
50
{
43
{
51
	static const char *modes[4][2] = {
44
	static const char *modes[4][2] = {
52
		{ "ab", "a" },
45
		{ "ab", "a" },
Line 159... Line 152...
159
	struct passwd *pwd = getpwuid(geteuid());
152
	struct passwd *pwd = getpwuid(geteuid());
Line 160... Line 153...
160
 
153
 
161
	if ((pwd == NULL) || (pwd->pw_dir == NULL))
154
	if ((pwd == NULL) || (pwd->pw_dir == NULL))
162
		return NULL;
155
		return NULL;
-
 
156
	sz_dir = strlen(pwd->pw_dir);
-
 
157
#elif defined _KOLIBRI
-
 
158
	char *kos_home = getenv("HOME");
-
 
159
	if (!kos_home)
-
 
160
		return NULL;
163
	sz_dir = strlen(pwd->pw_dir);
161
	sz_dir = strlen(kos_home);
164
#endif
162
#endif
165
	if (buf != NULL) {
163
	if (buf != NULL) {
166
		sz = *size;
164
		sz = *size;
167
#if	defined __MINGW32__ || defined _KOLIBRI
165
#if	defined __MINGW32__ || defined _KOLIBRI
Line 182... Line 180...
182
		if ((path = malloc(sz)) == NULL)
180
		if ((path = malloc(sz)) == NULL)
183
			return NULL;
181
			return NULL;
184
	}
182
	}
185
#ifndef __MINGW32__
183
#ifndef __MINGW32__
186
	#ifdef _KOLIBRI
184
	#ifdef _KOLIBRI
187
	strncpy(path, kos_dgen_userdir, sz_dir);
185
	strncpy(path, kos_home, sz_dir);
188
	#else
186
	#else
189
	strncpy(path, pwd->pw_dir, sz_dir);
187
	strncpy(path, pwd->pw_dir, sz_dir);
190
	#endif
188
	#endif
191
#else
189
#else
192
	if (SHGetFolderPath(NULL, (CSIDL_PROFILE | CSIDL_FLAG_CREATE),
190
	if (SHGetFolderPath(NULL, (CSIDL_PROFILE | CSIDL_FLAG_CREATE),
Line 232... Line 230...
232
	struct passwd *pwd = getpwuid(geteuid());
230
	struct passwd *pwd = getpwuid(geteuid());
233
	if ((pwd == NULL) || (pwd->pw_dir == NULL))
231
	if ((pwd == NULL) || (pwd->pw_dir == NULL))
234
		return NULL;
232
		return NULL;
235
	sz_dir = strlen(pwd->pw_dir);
233
	sz_dir = strlen(pwd->pw_dir);
236
	#else
234
	#else
-
 
235
	char *kos_home = getenv("HOME");
-
 
236
	if (!kos_home)
-
 
237
		return NULL;
237
	sz_dir = strlen(kos_dgen_userdir);
238
	sz_dir = strlen(kos_home);
238
	#endif
239
	#endif
239
#endif
240
#endif
Line 240... Line 241...
240
 
241
 
241
	if (sub != NULL)
242
	if (sub != NULL)
Line 264... Line 265...
264
	}
265
	}
265
#ifndef __MINGW32__
266
#ifndef __MINGW32__
266
	#ifndef _KOLIBRI
267
	#ifndef _KOLIBRI
267
	strncpy(path, pwd->pw_dir, sz_dir);
268
	strncpy(path, pwd->pw_dir, sz_dir);
268
	#else
269
	#else
269
	strncpy(path, kos_dgen_userdir, sz_dir);
270
	strncpy(path, kos_home, sz_dir);
270
	#endif
271
	#endif
271
#else
272
#else
272
	if (SHGetFolderPath(NULL, (CSIDL_APPDATA | CSIDL_FLAG_CREATE),
273
	if (SHGetFolderPath(NULL, (CSIDL_APPDATA | CSIDL_FLAG_CREATE),
273
			    0, 0, path) != S_OK) {
274
			    0, 0, path) != S_OK) {
274
		if (buf == NULL)
275
		if (buf == NULL)
Line 353... Line 354...
353
	else {
354
	else {
354
		if ((path = strdup(relative)) == NULL)
355
		if ((path = strdup(relative)) == NULL)
355
			goto error;
356
			goto error;
356
		size = strlen(path);
357
		size = strlen(path);
357
	}
358
	}
358
#ifndef KOLIBRI
359
 
359
	if ((mode & (DGEN_WRITE | DGEN_APPEND)) && (path != NULL))
360
	if ((mode & (DGEN_WRITE | DGEN_APPEND)) && (path != NULL))
360
		mkdir(path, 0777); /* XXX make that recursive */
361
		mkdir(path, 0777); /* XXX make that recursive */
361
#else
362
 
362
	mkdir(path, 0777);
-
 
363
#endif
-
 
364
	file_size = strlen(file);
363
	file_size = strlen(file);
365
	if ((tmp = realloc(path, (size + !!size + file_size + 1))) == NULL)
364
	if ((tmp = realloc(path, (size + !!size + file_size + 1))) == NULL)
366
		goto error;
365
		goto error;
367
	path = tmp;
366
	path = tmp;
368
	if (size)
367
	if (size)
Line 658... Line 657...
658
 * @param len Number of characters in "path" to match.
657
 * @param len Number of characters in "path" to match.
659
 * @return List of matching path names or NULL.
658
 * @return List of matching path names or NULL.
660
 */
659
 */
661
static char **complete_path_simple(const char *path, size_t len)
660
static char **complete_path_simple(const char *path, size_t len)
662
{
661
{
663
#ifndef _KOLIBRI
-
 
664
	size_t rlen;
662
	size_t rlen;
665
	const char *cpl;
663
	const char *cpl;
666
	char *root;
664
	char *root;
667
	struct dirent *dent;
665
	struct dirent *dent;
668
	DIR *dir;
666
	DIR *dir;
Line 743... Line 741...
743
	if (ret != NULL) {
741
	if (ret != NULL) {
744
		while (*ret != NULL)
742
		while (*ret != NULL)
745
			free(*(ret++));
743
			free(*(ret++));
746
		free(ret);
744
		free(ret);
747
	}
745
	}
748
#endif
746
 
749
	return NULL;
747
	return NULL;
750
}
748
}
Line 751... Line 749...
751
 
749