當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript File.exists方法代碼示例

本文整理匯總了TypeScript中file-system.File.exists方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript File.exists方法的具體用法?TypeScript File.exists怎麽用?TypeScript File.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在file-system.File的用法示例。


在下文中一共展示了File.exists方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: get

    get(url: string): Promise<string> {
        const appDir = knownFolders.currentApp().path;
        const templatePath = this.resolve(url, appDir);

        if (!File.exists(templatePath)) {
            throw new Error(`File ${templatePath} does not exist. Resolved from: ${url}.`);
        }
        let templateFile = File.fromPath(templatePath);
        return templateFile.readText();
    }
開發者ID:AhmedRagheb,項目名稱:nativescript-angular,代碼行數:10,代碼來源:xhr.ts

示例2: get

  get(url: string): Promise<string> {
      let appDir = knownFolders.currentApp().path;
      let templatePath = path.join(appDir, url);

      if (!File.exists(templatePath)) {
          throw new Error(`File ${url} does not exist.`);
      }
      let templateFile = File.fromPath(templatePath);
      return templateFile.readText();
  }
開發者ID:ImNitinNayar7,項目名稱:nativescript-angular,代碼行數:10,代碼來源:xhr.ts

示例3: loadStyles

function loadStyles() {
    var path = fs.path.join(fs.knownFolders.currentApp().path, cssPath);

    if (!fs.File.exists(path)) {
        throw new Error("Could not find code-highlight.css. Lookup path: " + path);
    }

    style = fs.File.fromPath(path).readTextSync((error) => {
        console.log("Error loading style file: " + error);
    });
};
開發者ID:phattranky,項目名稱:nativescript-marketplace-demo,代碼行數:11,代碼來源:code-page-view-model.ts

示例4: constructor

  constructor(protected path: string) {
    if (path.indexOf("~/") === 0) {
      this.path = path = fs.path.join(fs.knownFolders.currentApp().path, path.replace("~/", ""));
    }

    const documents = fs.knownFolders.currentApp();

    console.log('folder:', documents.path);

    fs.Folder.fromPath(fs.path.join(documents.path, '')).eachEntity(function (entity) {
      console.log('-', entity.name);
      // Return true to continue, or return false to stop the iteration.
      return true;
    });

    if (!fs.File.exists(path)) {
      console.error("Sound not initialized; file not found.");
      return;
    }
  };
開發者ID:m-abs,項目名稱:testing-nativescript,代碼行數:20,代碼來源:sound-common.ts

示例5: loadCss

export function loadCss(cssFile?: string): Array<cssSelector.CssSelector> {
    if (!cssFile) {
        return undefined;
    }

    var result: Array<cssSelector.CssSelector>;

    var fs: typeof fileSystemModule = require("file-system");
    var styleScope: typeof styleScopeModule = require("ui/styling/style-scope");

    var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, cssFile);
    if (fs.File.exists(cssFileName)) {
        var file = fs.File.fromPath(cssFileName);
        var applicationCss = file.readTextSync();
        if (applicationCss) {
            result = styleScope.StyleScope.createSelectorsFromCss(applicationCss, cssFileName);
        }
    }

    return result;
}
開發者ID:ImNitinNayar7,項目名稱:NativeScript,代碼行數:21,代碼來源:application-common.ts

示例6: loadCss

export function loadCss(cssFile?: string): RuleSet[] {
    if (!cssFile) {
        return undefined;
    }

    var result: RuleSet[];

    var fs: typeof fileSystemModule = require("file-system");
    if (!styleScope) {
        styleScope = require("ui/styling/style-scope");
    }

    var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, cssFile);
    if (fs.File.exists(cssFileName)) {
        var file = fs.File.fromPath(cssFileName);
        var applicationCss = file.readTextSync();
        if (applicationCss) {
            result = parseCss(applicationCss, cssFileName);
        }
    }

    return result;
}
開發者ID:CedarLogic,項目名稱:NativeScript,代碼行數:23,代碼來源:application-common.ts


注:本文中的file-system.File.exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。