当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript file-system.knownFolders类代码示例

本文整理汇总了TypeScript中file-system.knownFolders的典型用法代码示例。如果您正苦于以下问题:TypeScript knownFolders类的具体用法?TypeScript knownFolders怎么用?TypeScript knownFolders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了knownFolders类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Promise

    return new Promise(function (resolve, reject) {
      try {
        if (!options.image) {
          reject("no image specified");
          return;
        }

        const lang = options.language || "eng";

        const progressNotifier = new com.googlecode.tesseract.android.TessBaseAPI.ProgressNotifier({
          onProgressValues: (progressValues) => {
            if (options.onProgress) {
              options.onProgress(progressValues.getPercent());
            } else {
              console.log("Progress: " + progressValues.getPercent());
            }
          }
        });

        const tessBaseAPI = new com.googlecode.tesseract.android.TessBaseAPI(progressNotifier);
        tessBaseAPI.setDebug(false);

        const tessfolder = fs.path.join(fs.knownFolders.currentApp().path, "tesseract");

        const initSuccess = tessBaseAPI.init(tessfolder, lang, com.googlecode.tesseract.android.TessBaseAPI.OEM_TESSERACT_ONLY);
        // const initSuccess = tessBaseAPI.init(tessfolder, lang, com.googlecode.tesseract.android.TessBaseAPI.OEM_DEFAULT);

        if (!initSuccess) {
          reject("init failed");
          return;
        }

        // see https://github.com/rmtheis/tess-two/blob/master/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java#L53
        // tessBaseAPI.setPageSegMode(com.googlecode.tesseract.android.TessBaseAPI.PageSegMode.PSM_AUTO_OSD);
        // tessBaseAPI.setVariable(com.googlecode.tesseract.android.TessBaseAPI.VAR_SAVE_BLOB_CHOICES, com.googlecode.tesseract.android.TessBaseAPI.VAR_TRUE);

        if (options.whitelist) {
          tessBaseAPI.setVariable(com.googlecode.tesseract.android.TessBaseAPI.VAR_CHAR_WHITELIST, options.whitelist);
        }

        if (options.blacklist) {
          tessBaseAPI.setVariable(com.googlecode.tesseract.android.TessBaseAPI.VAR_CHAR_BLACKLIST, options.blacklist);
        }

        tessBaseAPI.setImage(options.image.android);
        const recognizedText = tessBaseAPI.getUTF8Text();

        tessBaseAPI.end();

        resolve({
          text: recognizedText
        });
      } catch (ex) {
        console.log("Error in ocr.retrieveText: " + ex);
        reject(ex);
      }
    });
开发者ID:EddyVerbruggen,项目名称:nativescript-ocr,代码行数:57,代码来源:ocr.android.ts

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: getSpeakerAvatars

function getSpeakerAvatars(path) {
    var avatarList: Array<string> = [];
    var currentAppFolder = fileSystemModule.knownFolders.currentApp();
    var menAvatarsFile = currentAppFolder.getFile(path);
    var fileText = menAvatarsFile.readTextSync();
    
    var lines = fileText.split('\n');
    for (var i = 0; i < lines.length; i++) {
        avatarList.push('data:image/png;base64,' + lines[i]);
    }
    return avatarList;
}
开发者ID:ArronNandoTech,项目名称:NativeScript-Demo,代码行数:12,代码来源:fake-data-service.ts

示例7: require

 toFile: (destinationFilePath?: string) => {
     var fs: typeof fsModule = require("file-system");
     var fileName = options.url;
     if (!destinationFilePath) {
         destinationFilePath = fs.path.join(fs.knownFolders.documents().path, fileName.substring(fileName.lastIndexOf('/') + 1));
     }
     if (data instanceof NSData) {
         data.writeToFileAtomically(destinationFilePath, true);
         return fs.File.fromPath(destinationFilePath);
     } else {
         reject(new Error(`Cannot save file with path: ${destinationFilePath}.`));
     }
 }
开发者ID:Prettycode-KC,项目名称:NativeScript,代码行数:13,代码来源:http-request.ios.ts

示例8: Promise

    return new Promise((resolve, reject) => {
      try {
        let MediaPlayer = android.media.MediaPlayer;
        let audioPath;

        let fileName = isString(options.audioFile) ? options.audioFile.trim() : "";
        if (fileName.indexOf("~/") === 0) {
          fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
          console.log('fileName: ' + fileName);
          audioPath = fileName;
        }

        this.player = new MediaPlayer();
          
        this.player.setAudioStreamType(android.media.AudioManager.STREAM_MUSIC);         
        this.player.setDataSource(audioPath);
        this.player.prepareAsync();

        // On Complete
        this.player.setOnCompletionListener(new MediaPlayer.OnCompletionListener({
          onCompletion: (mp) => {
            options.completeCallback();
          }
        }));

        // On Error
        this.player.setOnErrorListener(new MediaPlayer.OnErrorListener({
          onError: (mp: any, what: number, extra: number) => {
            options.errorCallback();
          }
        }));

        // On Info
        this.player.setOnInfoListener(new MediaPlayer.OnInfoListener({
          onInfo: (mp: any, what: number, extra: number) => {
            options.infoCallback();
          }
        }))

        // On Prepared
        this.player.setOnPreparedListener(new MediaPlayer.OnPreparedListener({
          onPrepared: (mp) => {
            mp.start();
            resolve();
          }
        }));

      } catch (ex) {
        reject(ex);
      }
    });
开发者ID:dwilanang,项目名称:nativescript-audio,代码行数:51,代码来源:player.ts

示例9: getFilenameFromUrl

export function getFilenameFromUrl(url: string) {
    const fs: typeof fsModule = require("file-system");
    const slashPos = url.lastIndexOf("/") + 1;
    const questionMarkPos = url.lastIndexOf("?");

    let actualFileName: string;
    if (questionMarkPos !== -1) {
        actualFileName = url.substring(slashPos, questionMarkPos);
    } else {
        actualFileName = url.substring(slashPos);
    }
    
    const result = fs.path.join(fs.knownFolders.documents().path, actualFileName);
    return result;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:15,代码来源:http-request-common.ts

示例10: ngOnInit

 ngOnInit() {
     var documents = knownFolders.currentApp();
     var jsonPersonFile = documents.getFile('dataform/data-services/person-model.json');
     var that = new WeakRef(this);
     jsonPersonFile.readText()
         .then(function (content) {
             try {
                 var person = JSON.parse(content);
                 that.get().person = person;
             } catch (err) {
                 throw new Error('Could not parse JSON file');
             }
         }, function (error) {
             throw new Error('Could not read JSON file');
         });
 }
开发者ID:haylahi,项目名称:mobile-app,代码行数:16,代码来源:dataform-getting-started-json.component.ts


注:本文中的file-system.knownFolders类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。