Skip to content

Commit 70b630b

Browse files
committed
add function image_move
1 parent d8a7c40 commit 70b630b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ Plugin
2121
drop function image_remove;
2222
drop function image_rename;
2323
drop function image_crc32;
24-
drop function image_md5sum;
24+
drop function image_move;
2525

2626
create function image_check returns string soname 'image.so';
2727
create function image_remove returns string soname 'image.so';
2828
create function image_rename returns string soname 'image.so';
2929
create function image_crc32 returns string soname 'image.so';
30-
create function image_md5sum returns string soname 'image.so';
30+
create function image_move returns string soname 'image.so';
3131

32-
select image_check('/tmp/filename');
33-
select image_remove('/tmp/filename');
34-
select image_rename('/tmp/aa','/tmp/bb');
35-
select image_crc32('/tmp/test.jpg');
36-
select image_md5sum('/tmp/test');
32+
select image_check('/path/filename.ext');
33+
select image_remove('/path/filename.ext');
34+
select image_rename('/path/oldfile.ext','/path/newfile.ext');
35+
select image_crc32('/path/filename.ext');
36+
select image_move('/path/filename.ext','/path/to/newfile.ext');

src/image.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,13 @@ char *image_move(UDF_INIT *initid, UDF_ARGS *args,
119119
{
120120

121121
char *data;
122-
data = "image_move";
122+
123+
if( rename(args->args[0], args->args[1]) == 0 ){
124+
data = "true";
125+
}else{
126+
data = "false";
127+
}
128+
//asprintf(&data, "ARG0=%s, ARG1=%d", args->args[0], args->args[1]);
123129
*length = strlen(data);
124130
return ((char *)data);
125131

0 commit comments

Comments
 (0)