Hey all,
So we have a alarm.txt file that we created on the a:/// of the TC65i-x, this file grew out of control as we commented out our control mechanism during testing, and has become about 3.45MB. This is causing that no other functions to be able to write anything to any files on the a:/// as all the space was taken up by this file plus the other files we have stored there.
Luckily we created a function that can download a file from the server and in this function it runs a file delete, however it doesn't work when the file is this large.
We tested the delete function and can confirm with a normal sized file 100kb, it deletes perfectly.
When we are trying to delete the 3.45MB file from the drive, we get a IOException:
java.io.IOException -
com.cinterion.io.j2me.file.Protocol..unknown.() bci=0 -
com.cinterion.io.j2me.file.Protocol..delete.().bci=116 -
.....
This is not really telling me much, the next steps we performed:
- Deleted the file via the MES
- Made the file smaller - about 2.83MB
- Uploaded the file back via MES
- Tried the same function as below and it worked perfectly
My current assumption is then:
- The delete function requires some buffer space to be able to run correctly - therefore since the entire flash is full it is failing to run?
- The delete function is somehow limited to a file size that it can delete?
Is there any AT command that I can issue to delete the file not using the API.
Here is the function that is deleting the file:
try
{
HttpConnection c = null;
InputStream is = null;
int rc;
c = (HttpConnection)Connector.open("http://" + Interchange.ServerIP + "/files/" + fileName);
// Getting the response code will open the connection,
// send the request, and read the HTTP response headers.
// The headers are stored until requested.
rc = c.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
return false;
}
is = c.openInputStream();
// Get the length and process the data
int len = (int)c.getLength();
if (len > 0)
{
FileConnection fconn = (FileConnection)Connector.open("file:///a:/" + fileName);
SystemIO.encryptOutput("Stream open going to download: " + fileName);
// If no exception is thrown, then the URI is valid, but the file
// may or may not exist.
if (!fconn.exists())
{
fconn.create();
}
else
{
fconn.delete();
fconn.create();
}
DataOutputStream dos = fconn.openDataOutputStream();
int actual = 0;
int bytesread = 0 ;
while ((bytesread != len) && (actual != -1))
{
byte[] data = new byte[1024];
actual = is.read(data, 0, 1024);
bytesread += actual;
SystemIO.encryptOutput("Read: " + bytesread);
dos.write(data, 0, actual);
}
}
else
return false;
is.close();
c.close();
return true;
}
catch (Exception ex)
{
SystemIO.printError("downloadFile", ex);
return false;
}