[ARCHIVER]
* BUG: The previous fix was incorrect. We can now really create an executable when the project directory and the target directory are not on the same device. git-svn-id: svn://localhost/gambas/trunk@5604 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
9f1286f161
commit
9cda9ad176
2 changed files with 18 additions and 11 deletions
|
@ -112,9 +112,9 @@ static void make_executable(void)
|
|||
const char *err;
|
||||
struct stat info;
|
||||
|
||||
FILE_chdir(FILE_get_dir(ARCH_project));
|
||||
FILE_chdir(FILE_get_dir(ARCH_output));
|
||||
|
||||
// If we cannot make the archive executable, just print a warning. gbs create an executable cache
|
||||
// If we cannot make the archive executable, just print a warning. gbs creates an executable cache
|
||||
// inside /tmp, and /tmp may be mounted with the "noexec" flag.
|
||||
|
||||
if (stat(TEMP_EXEC, &info) || chmod(TEMP_EXEC, info.st_mode | S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
|
@ -130,11 +130,8 @@ static void make_executable(void)
|
|||
|
||||
if (rename(TEMP_EXEC, ARCH_output))
|
||||
{
|
||||
if (FILE_copy(TEMP_EXEC, ARCH_output))
|
||||
{
|
||||
err = "Cannot create executable";
|
||||
goto __ERROR;
|
||||
}
|
||||
err = "Cannot create executable";
|
||||
goto __ERROR;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -196,7 +193,7 @@ void ARCH_init(void)
|
|||
|
||||
ALLOC(&arch_buffer, ARCH_BUFFER_SIZE);
|
||||
|
||||
arch_file = fopen(".temp.gambas", "w");
|
||||
arch_file = fopen(FILE_cat(FILE_get_dir(ARCH_output), TEMP_EXEC, NULL), "w");
|
||||
if (arch_file == NULL)
|
||||
THROW("Cannot create temporary archive file: &1", ARCH_output);
|
||||
|
||||
|
|
|
@ -1046,14 +1046,24 @@ bool FILE_copy(const char *src, const char *dst)
|
|||
ssize_t len;
|
||||
char *buf = NULL;
|
||||
int save_errno;
|
||||
struct stat info;
|
||||
|
||||
src_fd = open(src, O_RDONLY);
|
||||
if (src_fd < 0)
|
||||
fprintf(stderr, "FILE_copy: %s -> %s\n", src, dst);
|
||||
|
||||
if (stat(src, &info))
|
||||
return TRUE;
|
||||
|
||||
dst_fd = open(dst, O_WRONLY);
|
||||
src_fd = open(src, O_RDONLY);
|
||||
if (src_fd < 0)
|
||||
{
|
||||
fprintf(stderr, "open src failed\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
dst_fd = creat(dst, info.st_mode);
|
||||
if (dst_fd < 0)
|
||||
{
|
||||
fprintf(stderr, "open dst failed\n");
|
||||
save_errno = errno;
|
||||
close(src_fd);
|
||||
errno = save_errno;
|
||||
|
|
Loading…
Reference in a new issue