Press on the image to return to the main documentation page.
MLfiles
Written by Jem Miller - Missing Link Software
List of types:
MLfiles
Samba
SambaFile
MLfiles
Permissions:
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.NETWORK
android.permission.INTERNET
Events:
None
Members:
chmod
(
filename
As
String
,
permissions
As
String
)
As
Boolean
cp
(
Src
As
String
,
Dest
As
String
)
As
Boolean
cpr
(
Src
As
String
,
Dest
As
String
)
As
Boolean
createZipFile
(
path
As
String
)
dirEntries
(
Dir
As
String
)
As
java
.
util
.
ArrayList
ErrStr
As
String
Escape
(
fname
As
String
)
As
String
Exists
(
Filename
As
String
)
As
Boolean
extractZipFiles
(
zip_file
As
String
,
directory
As
String
)
extractZipFilesFromDir
(
zipName
As
String
,
fromDir
As
String
,
toDir
As
String
)
FSerror
As
String
fsStdOut
As
String
GetDiskstats
(
Path
As
String
)
As
String
GetFileDate
(
Fname
As
String
)
As
Long
GetFileExt
(
FName
As
String
)
As
String
GetFileType
(
Fname
As
String
)
As
String
GetFreespace
(
Path
As
String
)
As
Long
GetGigsFree
(
Path
As
String
)
As
Double
GetPerms
(
fname
As
String
)
As
String
GetRoot
GetSymlink
(
Fname
As
String
)
As
String
HaveBB
As
Boolean
HaveRoot
As
Boolean
HaveTB
As
Boolean
isDir
(
Path
As
String
)
As
Boolean
IsReadable
(
Fname
As
String
)
As
Boolean
isSymlink
(
Fname
As
String
)
As
Boolean
IsWritable
(
Fname
As
String
)
As
Boolean
mkdir
(
Dir
As
String
)
As
Boolean
mv
(
Oldname
As
String
,
Newname
As
String
)
As
Boolean
OutStr
As
String
ReadTxtFile
(
Fname
As
String
)
As
String
rm
(
Fname
As
String
)
As
Boolean
rmrf
(
Fname
As
String
)
As
Boolean
RootCmd
(
Command
As
String
,
Args
As
String
,
StdOut
As
StringBuilder
,
StdErr
As
StringBuilder
,
useBB
As
Boolean
)
As
Boolean
Sdcard
As
String
SdcardReady
As
String
SetFileDate
(
Fname
As
String
,
Time
As
Long
)
As
Boolean
Symlink
(
Linkname
As
String
,
Filename
As
String
)
As
Boolean
Touch
(
Fname
As
String
)
As
Boolean
WriteTxtFile
(
Fname
As
String
,
Txt
As
String
)
As
Boolean
zipPeek
(
zipname
As
String
)
As
java
.
util
.
ArrayList
Members description:
chmod
(
filename
As
String
,
permissions
As
String
)
As
Boolean
Sets file permissions for a file or directory. Requires correct user access or root.
Permissions are as Linux chmod numeric value.
1 = execute
2 = write
4 = read
644 = owner read/write (4 + 2), group read, other read
755 = owner read/write/execute (4 + 2 + 1), group read/execute, other read,execute
Uses Root if available.
cp
(
Src
As
String
,
Dest
As
String
)
As
Boolean
Copy a file from Src to Dest
Returns True on success.
Uses Root if available.
cpr
(
Src
As
String
,
Dest
As
String
)
As
Boolean
Recursive copy just like the Linux cp -r
Copies all files and directories under the Src path to Dest.
Works with directories, but is meaningless for files.
Returns True on success.
Uses Root if available.
createZipFile
(
path
As
String
)
Creates a backup zip of the directory path
dirEntries
(
Dir
As
String
)
As
java
.
util
.
ArrayList
Returns a list of formatted directory entries or an empty list on failure. As in :
d---rwxr-x system sdcard_rw 2011-11-13 12:59 LOST.DIR
Each element is in the form of a space separated string of
permissions and type (drwxr-xr-x) where the first char indicates a directory, link, or regular file (d, l, or -).
owner name
group name
file size
date
time
file name
Note that this method makes every attempt to fill in a size for symlinks and directories
This means that you should always get 7 fields.
Uses Root if available.
ErrStr
As
String
The StdErr interface used by most commands. This should
contain any error message from the OS.
Escape
(
fname
As
String
)
As
String
Escapes spaces, "(" and ")" characters in a filename
returns the original string if already escaped.
Exists
(
Filename
As
String
)
As
Boolean
Checks to see if a file exists.
Filename is the path and filename string
Returns True on success
extractZipFiles
(
zip_file
As
String
,
directory
As
String
)
Unzips a backup zipfile to directory.
directory will be created if needed.
extractZipFilesFromDir
(
zipName
As
String
,
fromDir
As
String
,
toDir
As
String
)
Unzips zipName from fromDir to toDir.
toDir will be created if needed.
FSerror
As
String
The value of stderror is set to this stringafter each call
if it is empty, there was no error.
fsStdOut
As
String
Contains the Linux StdOut result of a command. This is
what you would see in a Linux console if the command
is successful.
GetDiskstats
(
Path
As
String
)
As
String
Returns information of the given partition or pathname as a string formatted as
Size Used Free
each field is seperated with a single space.
For example:
[code]
Dim fs as MLFiles
Dim tmp as String
tmp = fs.GetDiskstats("/mnt/sdcard")
[/code}
In the example above, tmp Might return :
8G 57M 8G
If busybox is present, the output will be in bytes for each field.
Uses Root if available.
GetFileDate
(
Fname
As
String
)
As
Long
Gets the last modified date and time of a file or directory.
Returns the timestamp in milliseconds.
GetFileExt
(
FName
As
String
)
As
String
Returns the file extension (if available) of the file FName
otherwise returns the entire path and filename sent
GetFileType
(
Fname
As
String
)
As
String
Gets the filetype of Fname.
Returns file type as a String on success or Unknown on failure.
Returns standard mime types such as:
text/plain
audio/mpeg
text/XML
image/jpeg
as file types
GetFreespace
(
Path
As
String
)
As
Long
Returns the available space of the given partition/disk as a Long
Path is the mount point or directory within a partition
Note that some partitions are protected and will not return a value.
GetGigsFree
(
Path
As
String
)
As
Double
Returns the available space of the given partition/disk in gigabytes
Path is the partition path or directory within a partition
Format is a boolean that will convert the return value to a gigabyte number. Otherwise the number of bytes is returned.
Note that some partitions are protected and will not return a value.
GetPerms
(
fname
As
String
)
As
String
Example:
perms = GetPerms(filename)
Returns a Linux style permission string "rwxrwxrwx" rwx for each of owner, group, and others.
Use - for no permission, like "rw-r--r--" for owner read write, group read, and others read.
Works with files or directories.
GetRoot
Attempts to gain root access.
Sets HaveRoot to True on success
GetSymlink
(
Fname
As
String
)
As
String
Gets the target of a symbolic link in string format.
HaveBB
As
Boolean
True if busybox is installed.
HaveRoot
As
Boolean
True if GetRoot succeeds.
HaveTB
As
Boolean
True if toolbox is installed.
isDir
(
Path
As
String
)
As
Boolean
Returns true if Path is a directory
IsReadable
(
Fname
As
String
)
As
Boolean
Returns True if file or directory is readable to this user process.
isSymlink
(
Fname
As
String
)
As
Boolean
Returns True if file or directory is a symbolic link.
IsWritable
(
Fname
As
String
)
As
Boolean
Returns True if file or directory is writable to this user process.
mkdir
(
Dir
As
String
)
As
Boolean
Make a directory and any needed parent directories
Returns True on success
Uses Root if available.
mv
(
Oldname
As
String
,
Newname
As
String
)
As
Boolean
Use to move or rename files or directories from Oldname to Newname.
Returns True on success.
Uses Root if available.
OutStr
As
String
The StdOut interface returned by some commands. This
will contain what would normally be text output to a linux
terminal.
ReadTxtFile
(
Fname
As
String
)
As
String
Reads a text file and returns its contents in a StringBuilder.
Uses Root if available.
rm
(
Fname
As
String
)
As
Boolean
Remove (delete) a file or directory
Directories must be empty
Returns True on success.
Uses Root if available.
rmrf
(
Fname
As
String
)
As
Boolean
Remove (delete) a directory recursively.
ALL files and sub-directories will be deleted, EMPTY OR NOT.
Returns True on success.
Uses Root if available.
RootCmd
(
Command
As
String
,
Args
As
String
,
StdOut
As
StringBuilder
,
StdErr
As
StringBuilder
,
useBB
As
Boolean
)
As
Boolean
Executes a system command or program through the root adapter.
Uses standard permissions if root is not available.
Command - the command to execute
Args - the arguments to the command
StdOut - the text that would appear in a linux console
StdErr - any error text returned by the command
useBB - use busybox for the command if available
Returns true on success.
Sdcard
As
String
Returns the path to the external SD card if present as a string including the ending /
like /mnt/sdcard/
returns an empty string if not present
SdcardReady
As
String
Returns a state string for the external sdcard.
mounted = mounted and ready
unmounted = card present but unmounted
bad removal = sdcard removed without closing
removed = no card present
nofs = unformatted or unknown filesystem
shared = mount point is currently shared with usb device
unmountable = sdcard is present but damaged
checking = media is being scanned
mounted read only = sdcard is not writable
SetFileDate
(
Fname
As
String
,
Time
As
Long
)
As
Boolean
Sets file date and time on Fname to Time in milliseconds.
Returns True on success.
Symlink
(
Linkname
As
String
,
Filename
As
String
)
As
Boolean
Creates the symbolic link Linkname from Filename as in Linux/Unix.
Works on files or directories.
Returns True on success.
Uses Root if available.
Touch
(
Fname
As
String
)
As
Boolean
Creates an empty file with the current date and time.
Fname is the name of the file to create. If the file exists the datestamp is changed to NOW.
Returns True on success.
Uses root if available.
WriteTxtFile
(
Fname
As
String
,
Txt
As
String
)
As
Boolean
Writes the contents of Txt to the file Fname.
Fname must already exist or a FileNotFound exception is thrown.
Uses root if available.
zipPeek
(
zipname
As
String
)
As
java
.
util
.
ArrayList
Opens a zip file and returns the list of its contents
in a list.
zipname is the full path and filename to be displayed
Returns a formatted string of :
path/Name, compressed FileSize, and DateTime as a single semicolon separated string
Samba
Events:
None
Members:
Escape
(
fname
As
String
)
As
String
FSerror
As
String
mkSmbDirs
(
Dir
As
String
)
As
Boolean
SmbCopy
(
FromFile
As
String
,
ToFile
As
String
)
As
Boolean
SmbCredentials
(
Username
As
String
,
Password
As
String
,
Domain
As
String
)
SmbDelete
(
Url
As
String
,
SmbFile
As
String
)
As
Boolean
smbInStream
(
Afile
As
String
)
As
java
.
io
.
InputStream
SmbIP
(
host
As
String
)
As
String
SmbList
(
SmbUrl
As
String
,
Pattern
As
String
)
As
java
.
util
.
ArrayList
SmbMove
(
From
As
String
,
To
As
String
)
As
Boolean
Members description:
Escape
(
fname
As
String
)
As
String
Escapes spaces, "(" and ")" characters in a filename
Returns the original string if already escaped.
FSerror
As
String
mkSmbDirs
(
Dir
As
String
)
As
Boolean
Makes a directory on the Samba server.
This method will create any missing elements of the new path.
Returns True on success.
SmbCopy
(
FromFile
As
String
,
ToFile
As
String
)
As
Boolean
Copies a file TO or FROM the Samba server, including samba to samba copying.
Returns true on success.
SmbCredentials
(
Username
As
String
,
Password
As
String
,
Domain
As
String
)
Set the user name, password, and domain for a samba server
If set, this record will be passed to the server when the SmbList() is called.
SmbDelete
(
Url
As
String
,
SmbFile
As
String
)
As
Boolean
Deletes a file on the Samba server
Returns True on success.
smbInStream
(
Afile
As
String
)
As
java
.
io
.
InputStream
Creates an input stream from the file Afile that can be fed to another object.
Returns null if not successful.
SmbIP
(
host
As
String
)
As
String
Returns the IP address of the Samba server
SmbList
(
SmbUrl
As
String
,
Pattern
As
String
)
As
java
.
util
.
ArrayList
Returns a list of SmbFile types on the samba server.
Check the FSerror string to see if authentication failed or is needed.
SmbUrl = the SMB path to list
Pattern = an optional wildcard search pattern
SmbMove
(
From
As
String
,
To
As
String
)
As
Boolean
Moves or renames files or directories on the Samba server
Returns True on success.
SambaFile
The SmbFile type for manipulating individual files and directories on the Samba server.
Events:
None
Members:
CanRead
As
Boolean
CanWrite
As
Boolean
DiskFree
As
Long
GetPath
As
String
GetServer
As
String
GetShare
As
String
GetType
As
Int
isDir
As
Boolean
IsFile
As
Boolean
IsHidden
As
Boolean
IsInitialized
As
Boolean
LastModified
As
Long
Name
As
String
Parent
As
String
ServerIp
(
Server
As
String
)
As
String
Size
As
Long
TYPE_COMM
As
Int
TYPE_FILESYSTEM
As
Int
TYPE_NAMED_PIPE
As
Int
TYPE_PRINTER
As
Int
TYPE_SERVER
As
Int
TYPE_SHARE
As
Int
TYPE_WORKGROUP
As
Int
Members description:
CanRead
As
Boolean
True is the file or directory is readable.
CanWrite
As
Boolean
True if the directory or file can be written to.
DiskFree
As
Long
Returns the free space of this Samba share.
GetPath
As
String
Returns the SMB path to this file or directory
GetServer
As
String
Returns the Smaba server name
GetShare
As
String
Returns the share name
GetType
As
Int
Returns an Int representing the type of SMB object for this SambaFile from 0 through 6
TYPE_FILESYSTEM, a regular file or directory
TYPE_WORKGROUP, A workgroup
TYPE_SERVER, a Samba server
TYPE_SHARE, a shared directory
TYPE_PRINTER, a shared printer
TYPE_NAMED_PIPE, a named pipe
TYPE_COMM, a communications device
isDir
As
Boolean
Ckecks if this file is a directory.
IsFile
As
Boolean
True if this is a file and not a directory.
IsHidden
As
Boolean
True if this file or directory is hidden.
IsInitialized
As
Boolean
LastModified
As
Long
Returns the modify date of this file
Name
As
String
Returns the file name
Parent
As
String
Returns the parent directory
ServerIp
(
Server
As
String
)
As
String
Returns the IP address of the server
Size
As
Long
Returns the file size
TYPE_COMM
As
Int
TYPE_FILESYSTEM
As
Int
TYPE_NAMED_PIPE
As
Int
TYPE_PRINTER
As
Int
TYPE_SERVER
As
Int
TYPE_SHARE
As
Int
TYPE_WORKGROUP
As
Int
Top