Subversion Repositories Kolibri OS

Rev

Rev 8129 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8170 IgorA 1
#ifndef __KOLIBRI_FILE_OPEN_H_INCLUDED_
2
#define __KOLIBRI_FILE_OPEN_H_INCLUDED_
8129 IgorA 3
 
4
#include 
5
 
6
// Kolibri interface.
7
 
8
namespace Kolibri   // All kolibri functions, types and data are nested in the (Kolibri) namespace.
9
{
10
	struct TOpenFileStruct;   // Data for a file open dialog.
8170 IgorA 11
#define KOLIBRI_OPEN_FILE_INIT {}   // Initializer of the file open struct, cat be redefined in a realization of the library
8129 IgorA 12
 
13
	void OpenFileInit(TOpenFileStruct &ofs);
14
	void OpenFileDelete(TOpenFileStruct &ofs);
15
	bool OpenFileDialog(TOpenFileStruct &ofs);
16
	int OpenFileGetState(const TOpenFileStruct &ofs);
17
	bool OpenFileSetState(TOpenFileStruct &ofs, int state);
18
	char *OpenFileGetName(const TOpenFileStruct &ofs);
19
	bool OpenFileSetName(TOpenFileStruct &ofs, char *name);
20
}
21
 
8170 IgorA 22
#ifdef __KOLIBRI__
8129 IgorA 23
 
24
namespace Kolibri
25
{
26
// Structures.
27
 
28
	struct TOpenFileStruct
29
	{
30
		int state;
31
		char *name;
32
	};
8170 IgorA 33
#undef  KOLIBRI_OPEN_FILE_INIT
34
#define KOLIBRI_OPEN_FILE_INIT  {0,0}
8129 IgorA 35
 
36
// Inline functions.
37
 
38
	inline void OpenFileInit(TOpenFileStruct &ofs)
39
	{
40
		ofs.state = 0;
41
		ofs.name = 0;
42
	}
43
 
44
	inline void OpenFileDelete(TOpenFileStruct &ofs)
45
	{
46
		if (ofs.name) {Free(ofs.name); ofs.name = 0;}
47
	}
48
 
49
	inline int OpenFileGetState(const TOpenFileStruct &ofs)
50
	{
51
		return ofs.state;
52
	}
53
 
54
	inline char *OpenFileGetName(const TOpenFileStruct &ofs)
55
	{
56
		return ofs.name;
57
	}
58
 
59
// Functions.
60
 
61
	bool OpenFileSetState(TOpenFileStruct &ofs, int state)
62
	{
63
		if (!ofs.state) return !state;
64
		if (ofs.state == state) return true;
65
		if (state < 0) return false;
66
		ofs.state = state;
67
		return true;
68
	}
69
 
70
	bool OpenFileSetName(TOpenFileStruct &ofs, char *name)
71
	{
72
		if (!ofs.name && !name) return true;
73
		if (ofs.name) Free(ofs.name);
74
		if (!name) {ofs.name = 0; return true;}
75
		ofs.name = (char*)Alloc(StrLen(name) + 1);
76
		if (!ofs.name) return false;
77
		StrCopy(ofs.name, name);
78
		return true;
79
	}
80
}
81
 
8170 IgorA 82
#else   // else: def __KOLIBRI__
8129 IgorA 83
 
84
namespace Kolibri
85
{
86
	struct TOpenFileStruct
87
	{
88
		unsigned int data;
89
 
90
		TOpenFileStruct();
91
		~TOpenFileStruct();
92
	};
8170 IgorA 93
#undef  KOLIBRI_OPEN_FILE_INIT
94
#define KOLIBRI_OPEN_FILE_INIT  TOpenFileStruct()
8129 IgorA 95
}
96
 
8170 IgorA 97
#endif  // __KOLIBRI__
8129 IgorA 98
 
8170 IgorA 99
#endif  // __KOLIBRI_FILE_OPEN_H_INCLUDED_
8129 IgorA 100