本文整理汇总了TypeScript中tns-core-modules/file-system.path.join方法的典型用法代码示例。如果您正苦于以下问题:TypeScript path.join方法的具体用法?TypeScript path.join怎么用?TypeScript path.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tns-core-modules/file-system.path
的用法示例。
在下文中一共展示了path.join方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export var test_XmlParser_IntegrationTest = function () {
var actualResult = "";
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
if (event.eventType === xmlModule.ParserEventType.Text && event.data.trim() === "") {
// Ignore ignorable whitespace.
return;
}
actualResult += event.toString();
});
var file = fs.File.fromPath(fs.path.join(__dirname, "xml.xml"));
var xmlString = file.readTextSync();
xmlString = xmlString.replace(/(\r\n|\n|\r)/gm, "\n");
xmlParser.parse(xmlString);
var expectedResult: string;
file = fs.File.fromPath(fs.path.join(__dirname, "xml.expected"));
expectedResult = file.readTextSync();
var i;
var maxLength = Math.max(actualResult.length, expectedResult.length);
for (i = 0; i < maxLength; i++) {
var actualChar;
var actualCharCode;
if (i <= actualResult.length) {
actualChar = actualResult.charAt(i);
actualCharCode = actualResult.charCodeAt(i);
}
else {
actualChar = "undefined";
actualCharCode = "undefined";
}
var expectedChar;
var expectedCharCode;
if (i <= expectedResult.length) {
expectedChar = expectedResult.charAt(i);
expectedCharCode = expectedResult.charCodeAt(i);
}
else {
expectedChar = "undefined";
expectedCharCode = "undefined";
}
TKUnit.assert(actualCharCode === expectedCharCode, "At index " + i + ": Actual character is " + actualChar + "[" + actualCharCode + "]; Expected character is: " + expectedChar + "[" + expectedCharCode + "]");
}
};
示例2: test_DummyTestForSnippetOnly
export function test_DummyTestForSnippetOnly() {
// >> image-cache-request-images
var cache = new imageCacheModule.Cache();
cache.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png"));
cache.maxRequests = 5;
// Enable download while not scrolling
cache.enableDownload();
var imgSouce: imageSource.ImageSource;
var url = "https://github.com/NativeScript.png";
// Try to read the image from the cache
var image = cache.get(url);
if (image) {
// If present -- use it.
imgSouce = imageSource.fromNativeSource(image);
}
else {
// If not present -- request its download.
cache.push({
key: url,
url: url,
completed: (image: any, key: string) => {
if (url === key) {
imgSouce = imageSource.fromNativeSource(image);
}
}
});
}
// Disable download while scrolling
cache.disableDownload();
// << image-cache-request-images
}
示例3: function
export var test_getContentAsFile = function (done) {
var result;
// >> http-get-urlfile-content
var filePath = fs.path.join(fs.knownFolders.documents().path, "test.png");
http.getFile("https://httpbin.org/image/png?testQuery=query&anotherParam=param", filePath).then(function (r) {
//// Argument (r) is File!
// >> (hide)
result = r;
try {
TKUnit.assert(result instanceof fs.File, "Result from getFile() should be valid File object!");
done(null);
}
catch (err) {
done(err);
}
// << (hide)
}, function (e) {
//// Argument (e) is Error!
// >> (hide)
done(e);
// << (hide)
});
// << http-get-urlfile-content
};
示例4: getPlaceholderImageDrawable
public static getPlaceholderImageDrawable(value) {
let fileName = "",
drawable = null;
if (types.isString(value)) {
value = value.trim();
if (utils.isFileOrResourcePath(value)) {
if (0 === value.indexOf("~/")) {
fileName = fs.path.join(fs.knownFolders.currentApp().path, value.replace("~/", ""));
drawable = android.graphics.drawable.Drawable.createFromPath(fileName);
} else if (0 === value.indexOf("res")) {
fileName = value;
let res = utils.ad.getApplicationContext().getResources();
let resName = fileName.substr(utils.RESOURCE_PREFIX.length);
let identifier = res.getIdentifier(resName, 'drawable', utils.ad.getApplication().getPackageName());
drawable = res.getDrawable(identifier);
}
}
}
return drawable;
}
示例5: function
export var test_leading_slash_is_not_returned = function () {
var parts = ["app", "tns_modules", "fileName"];
var expected = parts.join("/");
var path = fs.path.join(...parts);
TKUnit.assertEqual(path, expected, "Leading slash should not be part of the path");
}
示例6: test_MultiParserTemplate
export function test_MultiParserTemplate() {
const file = fs.File.fromPath(fs.path.join(__dirname, "itemTemplates.xml"));
const xml = file.readTextSync();
const view: any = builder.parse(xml);
TKUnit.assertNotNull(view.items)
TKUnit.assertEqual(view.items.length, 1);
}
示例7: testSaveToFile_WithQuality
export function testSaveToFile_WithQuality() {
const img = imageSource.fromFile(imagePath);
const folder = fs.knownFolders.documents();
const path = fs.path.join(folder.path, "test.png");
const saved = img.saveToFile(path, "png", 70);
TKUnit.assert(saved, "Image not saved to file");
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
示例8: resolveRelativeUrls
private resolveRelativeUrls(url: string): string {
// Angular assembles absolute URLs and prefixes them with //
if (url.indexOf("/") !== 0) {
// Resolve relative URLs based on the app root.
return path.join(this.fs.currentApp().path, url);
} else {
return url;
}
}
示例9:
source.fromAsset(imageAsset).then((source) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png"
let path = fs.path.join(folder, fileName);
let saved = source.saveToFile(path, "png");
if(saved){
console.log("saved image")
}
})
示例10:
source.fromAsset(imageAsset).then((imageSource) => {
let folder = fs.knownFolders.documents().path;
let fileName = "test.png";
let path = fs.path.join(folder, fileName);
let saved = imageSource.saveToFile(path, "png");
if (saved) {
console.log("Image saved successfully!");
}
})