B4A Library File handling library

HotShoe

Well-Known Member
Licensed User
Longtime User

/system is mounted as read only by default. you'll need to remount it as rw to write to it.


hello ,

same error here, i tried all sort of combinations , but the lib reference to MLsmb does not show up (though it is there in IDE Tab)

could you see into this?

regards

There has to be something going on with so many reporting it. I will look into this later today.

Thanks,

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Well, you guys are right, MLsmb was broken. I use a file server to keep my projects and library source. That way I don't have to guess which machine has the latest version of a project/app/library, etc. Unfortunately, I did the separation of the libraries on a laptop and the version on the file server was a "work in progress" and not the finished version.

Please get the MLsmb-1.51.zip file attached to the first post and let me know if it still acts strange.

Thanks,

--- Jem
 

sanjibnanda

Active Member
Licensed User
Longtime User
Thanks ... works now.
 

tpakis

Active Member
Licensed User
Longtime User
Hello Jem, I am trying to run the sample smbtst, but i get "error listing smb://". The library and jcifs file are properly installed, any idea what's wrong?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Hello Jem, I am trying to run the sample smbtst, but i get "error listing smb://". The library and jcifs file are properly installed, any idea what's wrong?

Is Wifi is turned on and connected to your router ok?
 

HotShoe

Well-Known Member
Licensed User
Longtime User
2 or 3 others have reported this in the past, and I still don't know why a few can't get an smb link. It may have to do with router configuration or something in the code that I just can't see. In all of the other cases the b4a smb library works, so for now, I suggest you stick with that until I can find a reason for the failure and a solution. I have been through the SMB library and don't see anything structurally different in there than I am doing.

Thanks,

--- Jem
 

johndb

Active Member
Licensed User
Longtime User

Has this library been updated to allow the following on Samsung devices?
  • 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.
  • 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.

Thanks,

John
 

koaunglay

Member
Licensed User
Longtime User
Please help my error!
B4X:
** Activity (main) Create, isFirst = true **
java.lang.IllegalArgumentException: Invalid path:             900.0M   590.4M   309.6M   4096
    at android.os.StatFs.doStat(StatFs.java:46)
    at android.os.StatFs.<init>(StatFs.java:39)
    at MLfiles.Fileslib.MLfiles.GetGigsFree(MLfiles.java:623)
    at org.mlsoft.test.main._test(main.java:418)
    at org.mlsoft.test.main._activity_create(main.java:325)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at org.mlsoft.test.main.afterFirstLayout(main.java:100)
    at org.mlsoft.test.main.access$100(main.java:17)
    at org.mlsoft.test.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5457)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: statfs failed: ENOENT (No such file or directory)
    at libcore.io.Posix.statfs(Native Method)
    at libcore.io.ForwardingOs.statfs(ForwardingOs.java:131)
    at android.os.StatFs.doStat(StatFs.java:44)
    ... 19 more
java.lang.IllegalArgumentException: Invalid path:             900.0M   590.4M   309.6M   4096
 

koaunglay

Member
Licensed User
Longtime User
I want to make my parth!
B4X:
        Dim dsize As Double
        sd = fs.GetDiskstats("/data/user/0")    '    com.netqin.ps/databases/nqrecords.db
            If sd <> "" Then
                Msgbox("You have an external mounted at:" &sd, "Information")
'                        folderS = sd
'                        If File.Exists(folderS, "") = False Then
'                            ToastMessageShow("Not found!!!!!!", False)
'                            Return
'                        End If
'
            Else
                Msgbox("Not found anthing!!", "Information")
            End If
                   
       
        tmp1 = fs.SdcardReady
       
        If tmp1 <> "mounted" Then
            Msgbox("No usable found!", "Error")
            Activity.Finish
        End If
            dsize = Round2(fs.GetGigsFree(sd), 2)
           
            Msgbox("You have " & dsize & " available on sdcard", "Information")
           
        sd = fs.Sdcard
        tmp = sd & "MLtest/"
       
        ok = fs.mkdir(tmp)       
        ok = fs.Touch(tmp& "Test")
            If ok Then
                ok = fs.cp(tmp & "Test", tmp & "reText")
            End If
           
        fs.mkdir("/data/user/0/tst")
        ok = fs.cpr(tmp, "/data/user/0/tst")
       
        fs.GetRoot
        ok = fs.HaveRoot
        tmp1 = fs.fsStdOut
        If ok Then
            Msgbox("OK! Found Root Access!", "Info")
        Else
            Msgbox("No Root Access.", "Info")
        End If
'=====================

   
    filelis = fs.dirEntries(tmp)    '    fs.dirEntries(sd)    ' File.ListFiles(folderS)
    For i = 0 To filelis.Size -1
        DoEvents
'        Dim userInterfaceFile As String
'        userInterfaceFile = filelis.Get(i)
        lV.AddSingleLine(filelis.Get(i))
    Next
But I can't go on. There is some error in your sample zip for me. My English is not good. I mean..https://www.b4x.com/android/forum/threads/file-handling-library.19247/page-6#post-354002
 

koaunglay

Member
Licensed User
Longtime User
When I update MLfile v1.50 I get this error!
B4X:
** Activity (main) Create, isFirst = true **
java.lang.IllegalArgumentException: Invalid path: Filesystem               Size     Used     Free   Blksize
/mnt/sdcard            900.0M   590.4M   309.6M   4096
    at android.os.StatFs.doStat(StatFs.java:46)
    at android.os.StatFs.<init>(StatFs.java:39)
    at MLfiles.Fileslib.MLfiles.GetGigsFree(MLfiles.java:630)
    at org.mlsoft.test.main._test(main.java:418)
    at org.mlsoft.test.main._activity_create(main.java:325)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at org.mlsoft.test.main.afterFirstLayout(main.java:100)
    at org.mlsoft.test.main.access$100(main.java:17)
    at org.mlsoft.test.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5457)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: statfs failed: ENOENT (No such file or directory)
    at libcore.io.Posix.statfs(Native Method)
    at libcore.io.ForwardingOs.statfs(ForwardingOs.java:131)
    at android.os.StatFs.doStat(StatFs.java:44)
    ... 19 more
java.lang.IllegalArgumentException: Invalid path: Filesystem               Size     Used     Free   Blksize
/mnt/sdcard            900.0M   590.4M   309.6M   4096
 

HotShoe

Well-Known Member
Licensed User
Longtime User

From the error message it looks like you are running the code above while those lines are not commented out. In this case sd will be the return string from the getDiskStats call and cannot be used as an argument for the call to File.Exists (not a valid path). In the error, that string would equal:
Filesystem Size Used Free Blksize
/mnt/sdcard 900.0M 590.4M 309.6M 4096

Also be aware that /data is a protected path in android, so unless the device is rooted, you won't be able to read files or create a directory in that path.

--- Jem
 

koaunglay

Member
Licensed User
Longtime User
Thanks for your reply! I get the same error when I run your sample file /mnt/sdcard
 

koaunglay

Member
Licensed User
Longtime User
Thanks! The error from in log is running your sample file.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Actually, your sample above calls GetDiskStats as its first call, where the sample does not. It should look like this:

B4X:
Sub  test
   Dim dt As Long
   Dim ok As Boolean
   Dim l As List
   Dim arr, sd As String
   Dim i As Int
   Dim dsize As Double
   
   sd = fs.GetExtSd 'see if there is an external sdcard (internal cards are partitioned to make part look like an external card)
   
   If sd <> "" Then
   Msgbox("You have an external SD card mounted at: "&sd,"Information")
   Else
   Msgbox("I found no external SD card mounted","Information")
   End If
   
   tmp1 = fs.SdcardReady ' check the status of the card
   
   If tmp1 <> "mounted" Then  ' see if the card is usable
   Msgbox("No usable external sdcard found!","Error")
   Activity.Finish
   End If
   
   dsize = Round2(fs.getgigsfree(sd),2)
   
   Msgbox("You have " & dsize & " gigabytes available on your SD card","Information")
   
   sd = fs.Sdcard
   
   tmp = sd & "MLtest/" 'sdcard returns the path with a trailing /
   
   'Zip extraction test. Create and add a test.zip to your files to use this
'   File.Copy(File.DirAssets,"test.zip",sd,"test.zip")
'   
'   tmp1 = sd&"zipdir"
'   fs.extractZipFilesFromDir("test.zip", sd, tmp1)
   
   ok = fs.mkdir(tmp) ' make a new directory
   
   ok = fs.touch(tmp & "Test") 'create an empty file (or change the file access time/date to NOW if it exists)
   
   If ok Then
   ok = fs.cp(tmp & "Test", tmp & "reTest") ' copy the file
   End If
   
   fs.mkdir("/mnt/sdcard/tst") 'make a dir
   
   ok = fs.cpr(tmp,"/mnt/sdcard/tst") 'copy all files to the new dir
   
   fs.GetRoot ' see if we have root access
   ok = fs.HaveRoot
   
   tmp1 = fs.fsStdOut

   If ok Then
   Msgbox("I have Root access!","Information")
   Else
   Msgbox("I do not have Root access.","Information")
   End If
   
   l = fs.dirEntries(tmp, True) ' get file list of the new directory
   
   For i = 0 To l.Size - 1
   ListView1.AddSingleLine(l.Get(i))
   Next
   
   DoEvents
   
   l.Clear
   
   l = sf.SmbList("smb://",Null) 'get a list of all samba groups
   
   For i = 0 To l.Size - 1
   ListView2.AddSingleLine(l.Get(i))
   Next
   
   DoEvents
   
   tmp1 = fs.Escape("c:\Program Files (x86)") 'test the escape method (available in samba as well)
   Log(tmp1)
   
End Sub

--- Jem
 

koaunglay

Member
Licensed User
Longtime User
Is this code from your sample? Thanks. Let me try again.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…