B4A Library File handling library

HotShoe

Well-Known Member
Licensed User
Longtime User

I'm not seeing a problem with the exists method. Are you sure you are being granted superuser access? Is the device rooted? Your code looks ok so you might check that mlfiles1.haveroot = true to make sure you have root access.

Keep me informed,

--- Jem
 

biometrics

Active Member
Licensed User
Longtime User
Zip extraction failes and deletes zip file

Hi Jem,

I'm trying out 1.44 for unzipping. Both extractZipFiles and extractZipFilesFromDir fail to unzip the zip file and then deletes the zip file.

I can confirm the file exists before the call and is deleted after the call.

This is what I see in the B4A log (with filter off) after calling the extract functions:

GC_EXPLICIT freed 7K, 53% free 2580K/5379K, external 793K/1051K, paused 46ms
java.io.FileNotFoundException: /mnt/storage/sdcard/Our\ Player/Download/menu_3_23.zip (No such file or directory)
at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
at java.io.FileInputStream.<init>(FileInputStream.java:80)
at java.io.FileInputStream.<init>(FileInputStream.java:132)
at MLfiles.Fileslib.MLfiles.extractZipFiles(MLfiles.java:885)
at MLfiles.Fileslib.MLfiles.extractZipFilesFromDir(MLfiles.java:853)
at isenzo.download.main._libcontinuetimer_tick(main.java:1365)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3647)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
 

HotShoe

Well-Known Member
Licensed User
Longtime User
I'll try to get to the zip file error as soon as possible. My wife passed away yesterday morning and I'm not in the programming mode for the time being.

Thanks,

--- Jem
 

biometrics

Active Member
Licensed User
Longtime User
So sorry to hear that Jem. My condolences.

I'm using the Archiver library in the mean time but would obviously prefer not to include duplicate libraries.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
I have uploaded a new version of the library. See the first post in this thread for details.

--- Jem
 

rpina

Member
Licensed User
Longtime User
Hi Jem,
I'm using your library to copy files over network, but when I try this code

B4X:
Dim infile As String
infile=File.Combine(CartellaFoto,txtFileName.Text)
Dim outfile As String
outfile=fs.Escape(File.Combine("smb://192.2.0.36/Riccardo/",txtFileName.Text))
sf.SmbCopy(infile,outfile);

I get a input string format not correct during compiling process.

Can you help me?

Kind regards
Riccardo

Hi Jem,
I've solved my problem by rewriting this line of code

sf.SmbCopy(infile,outfile)

I don't know what happened, but now I can go on with development
 
Last edited:

rpina

Member
Licensed User
Longtime User
Hi Jem,
I'm facing a problem while trying to access a network folder.
When in my code I call following line

B4X:
l=sf.SmbList("smb://SVIL-02/Riccardo/",Null)

I receive in response from sf.FSerror

The system cannot find the file specified.

I've dowloaded smtst from post #36 and tryed it out.

All works well when listing from server like

B4X:
l=sf.SmbList("smb://SVIL-02/",Null)


But when I try to execute same statement as first one, error is the same.

When I use GetType it correctly says it is a TYPE_SHARE

Moreover, in first post I cannot find version 1.45 of your library. Can you check it out?

Kind regards

Riccardo
 
Last edited:

HotShoe

Well-Known Member
Licensed User
Longtime User

I have corrected the missing 1.45 .zip file. I guess I forgot to attach it. I'll do a simple addition to the smbtest project tonight and attach it to the first post as well to show how to handle directories and some file handling. Sorry for the delay in replying, I'll try to be around more.

Thanks,

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
File manager source

I have posted a link to my file manager app project in the first post. It is a complete project that demonstrates the various file handling methods for local and SMB connections.

It is mostly complete, but unfinished, and the link appears after the method descriptions and just before the version revisions in the first post of this thread. I will never do anything with this project and it may serve to help some of you with new ideas or ways of handling files.

It works with non-rooted or rooted devices.

Enjoy,

--- Jem
 

GMan

Well-Known Member
Licensed User
Longtime User
Hi HotShoe,

i tried out several samples, but still couldnt get it work.
Simply want to read out the content of a file "testfile.txt" on a shared pc-folder named "testdir".

Here's my code so far:

B4X:
Dim fs As MLfiles
Dim tmp As String
tmp = fs.ReadTxtFile("smb://notebook1/testdir/testfile.txt")
Msgbox(tmp,"Show content")

i grabbed before the path and showed it throug a messagebox to control it:
There stands (correct): smb://notebook1/testdir/testfile.txt

In the second messagebox where the content of the file should be showed stands nothing.
I got no error or similar, but also no content ;-)
 

HotShoe

Well-Known Member
Licensed User
Longtime User

You need to use the Samba routines to gain access to remote files. Get the smbtest.zip file attached to the first post for an example of how to use samba.

Thanks,

--- Jem
 

biggiu

Member
Licensed User
Longtime User
hi,
sorry fro my english

i try to create a new directory in the SD CARD but the program capture the error :

Msgbox("ERRORE IN FASE DI CREAZIONE DELLA CARTELLA dbase","ERRORE")



I check the permission status is ---rwxr-

I believe that this is the cause of the problem but do not know how to solve it.

code :


'----- Verifica Se Dispositivo Possiede SDSIM

sdRoot = SysAmb.Sdcard

Msgbox(sdRoot,"AVVISO")

'----- Verifica Stato SD Sim

StaSds =
SysAmb.SdcardReady

Msgbox(StaSds,"")

If StaSds <> "mounted"Then

Msgbox("DISPOSITIVO PRIVO DI SD-CARD, IMPOSSIBILE PROSEGUIRE!","Errore")

ReturnFalse

EndIf

LisFil =
File.ListFiles (File.dirassets)

For n = 0To LisFil.Size-1

OriDba = LisFil.Get(n)
Next

'----- Verifica Esistenza Ambiente di Lavoro

esito = True

NomFile = sdRoot & "dbase/saledb.sqlite"

DirDba =
sdRoot & "dbase/"

IfSysAmb.Exists(NomFile) = FalseThen

'----- Creazione Cartelle di lavoro

w1 = sdRoot & "dbase"

Log(w1)

Msgbox(w1,"AVVISO")

esito = SysAmb.mkdir(w1)

Ifesito = FalseThen

Msgbox("ERRORE IN FASE DI CREAZIONE DELLA CARTELLA dbase","ERRORE")

ReturnFalse

EndIf

'----- Copia DataBase

File.Copy (File.DirAssets, "saledb.sqlite", DirDba,"saledb.sqlite")

esito = False

EndIf
 

Turbo3

Active Member
Licensed User
Longtime User
Where can I get the jcifs.jar file? The mlsoft.sytes.net website is no longer available.
 

Turbo3

Active Member
Licensed User
Longtime User
I guess no one has run the example code which has an error in it.

Activity.LoadLayout("main") should not be conditioned by If FirstTime.

It needs to run each time Activity_Create is called or you get a not initialized error on the ListViews when you try to add to them after an orientation change.

To fix the missing jcifs.jar file I found a jcisf-1.3.17.jar and renamed it.
 

Turbo3

Active Member
Licensed User
Longtime User
Is this still the best way to find available free space on an SD card?
 

HotShoe

Well-Known Member
Licensed User
Longtime User


Doesn't surprise me that it's in the firsttime clause, but I'll change that. There is a link in the first post to the file.

--- Jem
 

Turbo3

Active Member
Licensed User
Longtime User
Yes, I tried that link before I posted but it was broken. I see now it is working again.
 

frankb4a

Member
Licensed User
Longtime User
Hi,
i got a Problem with SmbCopy and the SmbCredentials.

I can read the SMBList with my Credentials, but it wont let me do Copy or create Folders aso.
FSError said "unknown Username or Password".

But my User/Pass/Domain should be correct, cause the SMBLIST works fine.
Also the SMB Lib (V1.0) let me Copy Files with the same Credentials !
(but unfortunately it doesn't Support a MKDir at Samba)

I can't get anything else than SMBList to work.

What can be wrong ?

rg
Frank


B4X:
sf.SmbCredentials("Username","Pass","Domain")
    sf.SmbCopy(File.DirRootExternal & "/recovery.log","smb://Admin-Dev/Test/Test.log")
 

HotShoe

Well-Known Member
Licensed User
Longtime User
New version attached to first post. Many changes and fixes plus a couple additions.

--- Jem
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…