getSizeOfFile method
int
getSizeOfFile(
- Pointer<
ssh_session_struct> session, - String remoteFilePath, {
- bool isThrowException = true,
return total size in bytes of file , work on GNU/Linux systems, tested in debian 10 based on https://unix.stackexchange.com/questions/16640/how-can-i-get-the-size-of-a-file-in-a-bash-script/185039#185039
Implementation
int getSizeOfFile(Pointer<ssh_session_struct> session, String remoteFilePath,
{bool isThrowException = true}) {
//stat --format="%s" /var/www/html/'JUNHO 2021 - Controle de Dias Trabalhados.xlsx'
try {
var cmdToGetTotaSize = 'stat --format="%s" $remoteFilePath ';
var cmdRes = execCommandSync(session, cmdToGetTotaSize);
return int.parse(cmdRes);
} catch (e) {
print('getSizeOfFile: $e');
if (isThrowException) {
throw LibsshGetFileSizeException(
'Unable to get the size of a file in bytes');
}
}
return 0;
}