Skip to content

Commit

Permalink
fix(android): use specified Ti.Filesystem.File path to createFile() (#…
Browse files Browse the repository at this point in the history
…11099)

* fix(android): use specified Ti.Filesystem.File path to createFile()

Fixes TIMOB-27193

* test(android): add test case for createFile()
  • Loading branch information
sgtcoolguy authored and ssjsamir committed Sep 24, 2019
1 parent c697822 commit 37aace6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2018 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2011-2019 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand Down Expand Up @@ -169,11 +169,6 @@ public boolean createDirectory(@Kroll.argument(optional = true) Object arg)
@Kroll.method
public boolean createFile()
{
Context context = TiApplication.getInstance().getApplicationContext();
ContextWrapper contextWrapper = new ContextWrapper(context);
tbf = new TiFile(
new File(contextWrapper.getDir("data", Context.MODE_PRIVATE) + "/" + tbf.getNativeFile().getName()), path,
getExecutable());
return tbf.createFile();
}

Expand Down
22 changes: 22 additions & 0 deletions tests/Resources/ti.filesystem.file.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2019-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');

describe('Ti.Filesystem', () => {
it.android('TIMOB-27193', () => {
const filename = `TIMOB-27193_${Date.now()}.txt`;
const file = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, filename);
const originalPath = file.nativePath;
file.createFile();
should(file.exists()).eql(true);
// make sure we're not getting swindled by having the underlying file inside the proxy get changed on us!
should(file.nativePath).eql(originalPath);
});
});

0 comments on commit 37aace6

Please sign in to comment.