Delete file

Snippet deleting files from directory with specified name..

Opcode 0B00: delete_file "CLEO\log.txt" doesn't work with formated text directory.

To delete file you can use this snippet.:
PHP:
:DeleteFile
{
    0AC8: 0@ = allocate_memory_size 1024
    0AD3: 0@ = format "cleo\Stop.ini"
    0AB1: @DeleteFile 1 File 0@
}
if 0AA2: 31@ = load_dynamic_library "Kernel32.dll"
then
    if 0AA4: 30@ = get_dynamic_library_procedure "DeleteFileA" library 31@
    then 0AA7: call_function_return 30@ num_params 1 pop 0 0@ _StoreBooleanTo 29@
    end
    0AA3: free_dynamic_library 31@
end
0AB2: cleo_return 0
 

SamThapa

Active member
Joined
Jan 22, 2018
Messages
82
Reaction score
2
i need remove directory but no luck i try this

DeleteFile
{
0AC8: 0@ = allocate_memory_size 1024
0AD3: 0@ = format "modloader\vehicle\elegy" //this are directory not file so elegy is directory
0AB1: @DeleteFile 1 File 0@
}
if 0AA2: 31@ = load_dynamic_library "Kernel32.dll"
then
if 0AA4: 30@ = get_dynamic_library_procedure "RemoveDirectoryA" library 31@
then 0AA7: call_function_return 30@ num_params 2 pop 0 0 0@ _StoreBooleanTo 29@
end
0AA3: free_dynamic_library 31@
end
0AB2: cleo_return 0

how to delete subdirectory or folder that is inside other 2 folders ?
 

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
i need remove directory but no luck i try this

DeleteFile
{
0AC8: 0@ = allocate_memory_size 1024
0AD3: 0@ = format "modloader\vehicle\elegy" //this are directory not file so elegy is directory
0AB1: @DeleteFile 1 File 0@
}
if 0AA2: 31@ = load_dynamic_library "Kernel32.dll"
then
if 0AA4: 30@ = get_dynamic_library_procedure "RemoveDirectoryA" library 31@
then 0AA7: call_function_return 30@ num_params 2 pop 0 0 0@ _StoreBooleanTo 29@
end
0AA3: free_dynamic_library 31@
end
0AB2: cleo_return 0

how to delete subdirectory or folder that is inside other 2 folders ?
PHP:
{$CLEO .cs}
{$USE file}
0000:

WHILE TRUE
WAIT 0

IF 0ADC:   test_cheat "K" 
THEN
    IF 0AE4:   does_directory_exist "modloader\vehicle\elegy"
    THEN
        0B01: delete_directory "modloader\vehicle\elegy" include_subdirs 1
        0AD1: "~g~Success!" 3000
    ELSE
        0AD1: "~r~Failure!" 3000
    END
END

END
0A93: terminate_this_custom_script
 

Attachments

  • Script.cs
    17.6 KB · Views: 2

SamThapa

Active member
Joined
Jan 22, 2018
Messages
82
Reaction score
2
PHP:
{$CLEO .cs}
{$USE file}
0000:

WHILE TRUE
WAIT 0

IF 0ADC:   test_cheat "K"
THEN
    IF 0AE4:   does_directory_exist "modloader\vehicle\elegy"
    THEN
        0B01: delete_directory "modloader\vehicle\elegy" include_subdirs 1
        0AD1: "~g~Success!" 3000
    ELSE
        0AD1: "~r~Failure!" 3000
    END
END

END
0A93: terminate_this_custom_script
tysm and yea it works but i try something else

{$CLEO .cs}
0000:

WHILE TRUE
WAIT 0
IF 0ADC: test_cheat "K"
THEN alloc 1@ = 2048
0AD3: string 1@ format "Modloader\AddedVeh\elegy" //i use this because not only 1 folder sometimes i use some mods and if dont like it wanted to delete it after choosing it
IF 0AE4: does_directory_exist 1@
THEN 0B01: delete_directory 1@ include_subdirs 1
0AD1: "~g~Success %s" 3000 1@
ELSE 0AD1: "~r~Failure %s" 3000 1@
END
free 1@
wait 500
END
END
0A93: terminate_this_custom_script
 
Top