Zig
Zig
Remove Directory
See more FTP Examples
Delete a remote FTP directory.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const ftp = try chilkat.Ftp2.init();
defer ftp.deinit();
ftp.setHostname("ftp.example.com");
ftp.setUsername("login");
ftp.setPassword("password");
// Connect and login to the FTP server.
ftp.connect() catch {
std.debug.print("{s}\n", .{try ftp.getLastErrorText(alloc)});
return;
};
// Delete a directory on the FTP server. The directory
// must not contain any files, otherwise an error status
// will be returned. Most FTP servers do not allow
// directories containing files to be deleted.
ftp.removeRemoteDir("newDirName") catch {
std.debug.print("{s}\n", .{try ftp.getLastErrorText(alloc)});
return;
};
try ftp.disconnect();
}