makeDirectory method
Implementation
Future<void> makeDirectory(String dirname) async {
if (dirname.isEmpty) {
sendResponse('501 Syntax error in parameters');
return;
}
try {
await fileOperations.createDirectory(dirname);
// RFC 959: 257 response must contain the absolute FTP pathname.
// Temporarily change into the new dir to get its resolved virtual path,
// then change back to the original directory.
final savedDir = fileOperations.getCurrentDirectory();
try {
fileOperations.changeDirectory(dirname);
final absPath = fileOperations.getCurrentDirectory();
sendResponse('257 "$absPath" created');
} finally {
fileOperations.changeDirectory(savedDir);
}
} catch (e) {
sendResponse('550 Failed to create directory');
logger.generalLog('Error creating directory: $e');
}
}