[INTERPRETER]
* NEW: Remove the unused GB.ExistFile() API. * NEW: Exist() now takes an additional optional boolean argument that tells if symbolic links must be followed, like Stat(). * BUG: Fix a possible memory leak if the [...] array creation operator fails for any reason. git-svn-id: svn://localhost/gambas/trunk@3940 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
f2208643c2
commit
d0b8c37638
14 changed files with 32 additions and 32 deletions
|
@ -485,7 +485,6 @@ Private Sub FillWithSpecial()
|
|||
|
||||
End
|
||||
|
||||
|
||||
' PUBLIC SUB Form_Resize()
|
||||
'
|
||||
' 'PRINT "Form_Resize: ME.H = "; ME.H; " Me.ClientH =";ME.ClientH
|
||||
|
|
|
@ -33,7 +33,7 @@ Public Sub Form_Open()
|
|||
tabBrowser_Click
|
||||
'txtURL.Text = "http://gambas.sourceforge.net"
|
||||
'txtURL_Activate
|
||||
|
||||
|
||||
End
|
||||
|
||||
Private Sub GetView() As WebView
|
||||
|
|
|
@ -36,12 +36,12 @@ SearchComment=False
|
|||
SearchString=True
|
||||
|
||||
[OpenFile]
|
||||
File[1]=".src/MMain.module:36.32"
|
||||
Active=1
|
||||
File[1]=".src/MMain.module:30.2"
|
||||
File[2]=".src/DBusApplication.class:92.29"
|
||||
File[3]=".src/DBus.class:9.0"
|
||||
File[4]=".src/DBusProxy.class:154.0"
|
||||
Active=5
|
||||
File[5]=".src/DBusObject.class:391.2"
|
||||
File[5]=".src/DBusObject.class:390.7"
|
||||
File[6]=".src/CTest.class:11.2"
|
||||
File[7]=".src/DBusSignal.class:18.3"
|
||||
Count=7
|
||||
|
|
|
@ -170,7 +170,6 @@ void *GAMBAS_Api[] =
|
|||
|
||||
(void *)GB_LoadFile,
|
||||
(void *)STREAM_unmap,
|
||||
(void *)FILE_exist,
|
||||
(void *)GB_TempDir,
|
||||
(void *)GB_TempFile,
|
||||
(void *)GB_CopyFile,
|
||||
|
@ -1378,6 +1377,12 @@ bool GB_LoadFile(const char *path, int lenp, char **addr, int *len)
|
|||
}
|
||||
|
||||
|
||||
bool GB_ExistFile(const char *path)
|
||||
{
|
||||
return FILE_exist(path);
|
||||
}
|
||||
|
||||
|
||||
void GB_Store(GB_TYPE type, GB_VALUE *src, void *dst)
|
||||
{
|
||||
if (src != NULL)
|
||||
|
|
|
@ -91,6 +91,7 @@ bool GB_ExistClassLocal(const char *name);
|
|||
char *GB_ToZeroString(GB_STRING *src);
|
||||
|
||||
bool GB_LoadFile(const char *path, int lenp, char **addr, int *len);
|
||||
bool GB_ExistFile(const char *path);
|
||||
//void GB_ReleaseFile(char **addr, int len);
|
||||
#define GB_ReleaseFile STREAM_unmap
|
||||
char *GB_RealFileName(const char *path, int len);
|
||||
|
|
|
@ -241,7 +241,7 @@ static GB_DESC NATIVE_GambasLanguage[] =
|
|||
GB_METHOD("Lof", "l", NULL, "[(File)Stream;]"),
|
||||
GB_METHOD("Seek", "l", NULL, "(File)Stream;"),
|
||||
|
||||
GB_METHOD("Exist", "b", NULL, "(Path)s"),
|
||||
GB_METHOD("Exist", "b", NULL, "(Path)s[(FollowLink)b]"),
|
||||
GB_METHOD("Stat", "Stat", NULL, "(Path)s[(FollowLink)b]"),
|
||||
|
||||
GB_METHOD("Temp$", "s", NULL, "[(Prefix)s]"),
|
||||
|
|
|
@ -323,7 +323,7 @@ void EXEC_loop(void)
|
|||
/* 88 Move */ &&_SUBR,
|
||||
/* 89 Copy */ &&_SUBR,
|
||||
/* 8A Link */ &&_SUBR,
|
||||
/* 8B Exist */ &&_SUBR,
|
||||
/* 8B Exist */ &&_SUBR_CODE,
|
||||
/* 8C Access */ &&_SUBR_CODE,
|
||||
/* 8D Stat */ &&_SUBR_CODE,
|
||||
/* 8E Dfree */ &&_SUBR,
|
||||
|
|
|
@ -198,7 +198,7 @@ void SUBR_lock(ushort code);
|
|||
void SUBR_inp_out(ushort code);
|
||||
|
||||
void SUBR_stat(ushort code);
|
||||
void SUBR_exist(void);
|
||||
void SUBR_exist(ushort code);
|
||||
void SUBR_dir(ushort code);
|
||||
void SUBR_kill(void);
|
||||
void SUBR_mkdir(void);
|
||||
|
|
|
@ -511,16 +511,20 @@ void SUBR_stat(ushort code)
|
|||
}
|
||||
|
||||
|
||||
void SUBR_exist(void)
|
||||
void SUBR_exist(ushort code)
|
||||
{
|
||||
bool exist;
|
||||
const char *path;
|
||||
bool follow = FALSE;
|
||||
|
||||
SUBR_ENTER_PARAM(1);
|
||||
SUBR_ENTER();
|
||||
|
||||
path = get_path(PARAM);
|
||||
|
||||
exist = FILE_exist(path);
|
||||
if (NPARAM == 2)
|
||||
follow = SUBR_get_boolean(&PARAM[1]);
|
||||
|
||||
exist = FILE_exist_follow(path, follow);
|
||||
|
||||
RETURN->type = T_BOOLEAN;
|
||||
RETURN->_integer.value = exist ? -1 : 0;
|
||||
|
|
|
@ -299,7 +299,6 @@ _FREE:
|
|||
SUBR_LEAVE();
|
||||
}
|
||||
|
||||
|
||||
void SUBR_array(ushort code)
|
||||
{
|
||||
TYPE type;
|
||||
|
@ -313,17 +312,18 @@ void SUBR_array(ushort code)
|
|||
if (type == T_NULL)
|
||||
type = T_OBJECT;
|
||||
|
||||
for (i = 0; i < NPARAM; i++)
|
||||
VALUE_conv(&PARAM[i], type);
|
||||
|
||||
GB_ArrayNew(&array, type, NPARAM);
|
||||
OBJECT_REF(array, "SUBR_array");
|
||||
|
||||
// FIXME: If there is an error, the array is not freed!
|
||||
for (i = 0; i < NPARAM; i++)
|
||||
{
|
||||
VALUE_conv(&PARAM[i], type);
|
||||
GB_Store(type, (GB_VALUE *)&PARAM[i], GB_ArrayGet(array, i));
|
||||
RELEASE(&PARAM[i]);
|
||||
}
|
||||
|
||||
OBJECT_REF(array, "SUBR_array");
|
||||
|
||||
PARAM->_object.class = OBJECT_class(array); //CLASS_Array;
|
||||
PARAM->_object.object = array;
|
||||
SP = PARAM + 1;
|
||||
|
|
|
@ -887,7 +887,6 @@ typedef
|
|||
|
||||
bool (*LoadFile)(const char *, int, char **, int *);
|
||||
void (*ReleaseFile)(char *, int);
|
||||
bool (*ExistFile)(char *);
|
||||
char *(*TempDir)(void);
|
||||
char *(*TempFile)(const char *);
|
||||
bool (*CopyFile)(const char *, const char *);
|
||||
|
|
|
@ -94,8 +94,6 @@ bool FILE_is_dir(const char *path);
|
|||
|
||||
const char *FILE_find_gambas(void);
|
||||
|
||||
bool FILE_exist(const char *path);
|
||||
|
||||
void FILE_rename(const char *src, const char *dst);
|
||||
void FILE_unlink(const char *path);
|
||||
|
||||
|
@ -105,6 +103,8 @@ void FILE_init(void);
|
|||
void FILE_remove_temp_file(void);
|
||||
void FILE_exit(void);
|
||||
|
||||
bool FILE_exist_follow(const char *path, bool follow);
|
||||
#define FILE_exist(_path) FILE_exist_follow(_path, FALSE)
|
||||
bool FILE_exist_real(const char *path);
|
||||
|
||||
void FILE_stat(const char *path, FILE_STAT *info, bool follow);
|
||||
|
@ -128,6 +128,7 @@ int64_t FILE_free(const char *path);
|
|||
|
||||
#else
|
||||
|
||||
bool FILE_exist(const char *path);
|
||||
time_t FILE_get_time(const char *path);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -812,23 +812,14 @@ bool FILE_access(const char *path, int mode)
|
|||
}
|
||||
|
||||
|
||||
bool FILE_exist(const char *path)
|
||||
bool FILE_exist_follow(const char *path, bool follow)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (FILE_is_relative(path))
|
||||
{
|
||||
/*if (!EXEC_arch)
|
||||
{
|
||||
chdir(PROJECT_path);
|
||||
if (lstat(path, &buf) == 0)
|
||||
return TRUE;
|
||||
}*/
|
||||
|
||||
return ARCHIVE_exist(NULL, path);
|
||||
}
|
||||
|
||||
return lstat(path, &buf) == 0;
|
||||
return follow ? (stat(path, &buf) == 0) : (lstat(path, &buf) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -454,7 +454,7 @@ SUBR_INFO COMP_subr_info[] =
|
|||
{ ".Copy", 73, 0, 2 },
|
||||
{ ".Link", 74, 0, 2 },
|
||||
#endif
|
||||
{ "Exist", 75, 0, 1 },
|
||||
{ "Exist", 75, 0, 1, 2 },
|
||||
{ "Access", 76, 0, 1, 2 },
|
||||
{ "Stat", 77, 0, 1, 2 },
|
||||
{ "Dfree", 78, 0, 1 },
|
||||
|
|
Loading…
Reference in a new issue