[TIMOB-3052] Android: Ti.Filesystem.File.write should return boolean
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T02:00:47.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.7.0, Sprint 2011-11 |
Components | Android |
Labels | android, feature, release-1.7.0, reported-1.6.0, rplist |
Reporter | Dawson Toth |
Assignee | Don Thorp |
Created | 2011-04-15T03:35:34.000+0000 |
Updated | 2011-04-17T02:00:47.000+0000 |
Description
Problem
On iOS, the "write" function on a Ti.Filesystem.File returns true or false depending on if the write was successful, or false if it's not possible to write to the file or blob. Android doesn't return anything.
Sample Code
var file = Titanium.Filesystem.createTempFile();
if (file.write('my super cool data') === true) {
alert('PASS: I wrote to a file! YESSS!');
}
else {
alert('FAIL: I am sad, for I could not tell you I wrote to the file. Weep weep weep.');
}
Tested On
Titanium SDK version: 1.6.0 (02/02/11 15:22 a02f7db...)
PASSES on iOS Simulator 4.2
FAILS on Android Simulator 2.2
Related Documentation
The docs already state that "write" returns a boolean, most
likely because that's what iOS does.
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem.File.write-method.html">
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Fil...
Associated Helpdesk Ticket
http://developer.appcelerator.com/helpdesk/view/70481">http://developer.appcelerator.com/helpdesk/view/70481
Attachments
File | Date | Size |
---|---|---|
app.js | 2011-04-15T03:35:34.000+0000 | 1406 |
Also note that this is causing a RHINO USAGE WARNING. It is definitely caused by trying to pull a value out of file.write('whatever'), as demonstrated here:
Rhino Usage Warning
Sample Code
This is all you need in your app.js. Simple, huh? When the app launches, you should see the warning message.
Trace Level Log
Tested On
Titanium SDK version: 1.6.0 (02/02/11 15:22 a02f7db...)
Occurs on Android Simulator 2.2
(from [2b9fd7dae1c45c8bf55b0d930659494c05ec3ebc]) [#3052 state:fixed-in-qa] change File write to return a boolean value
changed write method on file object to return a boolean value indicating whether the write was successful or not
https://github.com/appcelerator/titanium_mobile/commit/2b9fd7dae1c45c8bf55b0d930659494c05ec3ebc"> https://github.com/appcelerator/titanium_mobile/commit/2b9fd7dae1c4...
Please verify fix with the attached app.s. When running, you should see:
03-16 20:01:48.546: INFO/ALERT(437): (kroll$1: app://app.js) [2717,13782] PASS: I wrote to a file! YESSS!
Tested with Titanium SDK version: 1.7.0 (03/16/11 13:28 2b9fd7d) on
Nexus S 2.3.2
I/ALERT ( 1071): (kroll$3: app://app.js) [323,396] PASS: I wrote to a file! YESSS!
Emulator 2.1
[TRACE] I/ALERT ( 275): (kroll$1: app://app.js) [430,772] PASS: I wrote to a file! YESSS!