Can I get the unix permissions also SFTP? Can not do anything with Posix and I absolutely need the PermType Unix.
Can you implement it? Thx Christian
asked Jul 20 '15 at 04:09
The SFtpFile.Permissions integer property is the Unix permissions.
answered Jul 20 '15 at 10:03
How can I translate this value Integer? Into 0644 maybe
Can you post an example?
answered Jul 20 '15 at 10:55
0644 is the octal representation of the integer.
An integer is a binary number -- a sequence of 1's and 0's. In binary, 0644 looks like this:
Displaying it as an octal number, each octal digit is 3 bits. Therefore we have this:
110 100 100
Displaying it as a hexidecimal number, each hex digit is 4 bits. Therefore we have this:
0001 1010 0100 (In hex this is 0x1A4)
In C/C++, you might use sprintf(buf,"%o",permVal);
answered Jul 21 '15 at 08:22
The return of GetFilePermission is not a binary value, it's a Long Value (Visual Basic):
I have researched many hours, here is my result:
perm = sftp.GetFilePermissions ("Test Folder", 0, 0)
'Perm = 16837' which is a Long value
OctPerm = Oct $ (perm) 'OctPerm = 40705
The first digit of 4 represents a folder, the rest behind the Unix permisson
perm = sftp.GetFilePermissions ("Test File", 0, 0)
'Perm = 33156' which is a Long value
OctPerm = Oct$(perm) 'OctPerm = 100604
The first two digits 10 stands for a file, the rest behind the Unix permisson
To change an access right now, I need to convert the value Long permisson into a octal number. Then I have to change the octal number, and then convert back again in a Long value to apply SetFilePermissions.
Private Function OctToDec (OctValue As String) As Long
Dim x As Long Dim value As Long
For x = 0 To Len (OctValue) - 1
Value = value + CLng (Mid $ (OctValue, Len (OctValue) - x, 1)) * 8 ^ x
OctToDec = value
Or do I still have a flaw?
answered Jul 22 '15 at 01:59
In VB6 you have language provided ways to convert DEC<>OCT.
For example, converting a Base10 Decimal # to Base 8 Octal:
Debug.Print Oct(33156) ' Will print 100604 to the debug/immediate window
To convert from Octal to Decimal, prepend you octal number with &O and convert to Long as follows:
Debug.Print CLng("&O" & 100604) ' Will print 33156 to the debug/immediate window
answered Jul 22 '15 at 08:12
Thanks for the answer. But my function OctToDec also runs very well.
answered Jul 23 '15 at 08:22