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


TypeScript fs.rename函數代碼示例

本文整理匯總了TypeScript中fs.rename函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript rename函數的具體用法?TypeScript rename怎麽用?TypeScript rename使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: HttpError

    var promises = files.map((file)=> {
      var guid
      if (body.info) {
        var info = JSON.parse(body.info)
        if (info.guid) {
          if (!info.guid.match(/[\w\-]+/))
            throw new HttpError('Invalid guid: ' + info.guid + '.', 400)

          guid = info.guid
        }
      }

      guid = guid || uuid.v1()

      var path = require('path')
      var ext = path.extname(file.originalname) || ''
      var filename = guid + ext
      var filepath = (this.config.paths.files) + '/' + filename
      var fs = require('fs')
      fs.rename(file.path, filepath);

      // !!! Add check if file already exists
      return this.ground.update_object('file', {
        guid: guid,
        name: filename,
        path: file.path,
        size: file.size,
        extension: ext.substring(1),
        status: 1
      }, user)
    })
開發者ID:silentorb,項目名稱:vineyard-cellar,代碼行數:31,代碼來源:cellar.ts

示例2: function

            fs.readdirSync(src).forEach(function (childItemName) {

                fs.rename(
                    path.resolve(src, childItemName),
                    path.resolve(src, childItemName.replace("project", projectName)), function (e) {
                        if (e) throw e;
                    });
            });
開發者ID:odtorres,項目名稱:Alfresco-VSCode,代碼行數:8,代碼來源:AlfrescoBuidTools.ts

示例3: reject

 return new Promise<void>((resolve, reject) => {
     fs.rename(oldName, newName, err => {
         if (err) {
             return reject(err);
         }
         return resolve();
     });
 });
開發者ID:swyphcosmo,項目名稱:vscode-cpptools,代碼行數:8,代碼來源:common.ts

示例4: Promise

 const promise = new Promise((resolve, reject) => {
   fs.rename(filePath, newFilePath, (err: NodeJS.ErrnoException) => {
     if (err) {
       reject(err);
     } else {
       resolve();
     }
   });
 });
開發者ID:screendriver,項目名稱:redater,代碼行數:9,代碼來源:redater.ts

示例5: reject

 return new Promise<void>((resolve, reject) => {
   fs.rename(from, to, (err) => {
     if (err) {
       reject(err);
     } else {
       resolve();
     }
   });
 });
開發者ID:devCrossNet,項目名稱:angular-cli,代碼行數:9,代碼來源:fs.ts

示例6: function

 const promise = new Promise<void>(function(resolve, reject) {
    fs.rename(src, dest, function(err) {
        if (err) {
            reject(err.code);
        } else {
            resolve();
        }
    });
 });
開發者ID:Jeffiy,項目名稱:omnisharp-vscode,代碼行數:9,代碼來源:main.ts

示例7: Promise

 return new Promise((resolve, reject) => {
     fs.rename(oldPath, newPath, (err: any) => {
         if (err) {
             reject(err);
         } else {
             resolve();
         }
     });
 });
開發者ID:eez-open,項目名稱:studio,代碼行數:9,代碼來源:util-electron.ts

示例8: onFileReadFunction

 fs.readFile(__path__, 'utf-8', (err, _) => {
     if (err) throw err;
     const pathStart = filename.split('.')[0];
     if (pathStart === '') throw err;
     fs.rename(__path__, onFileReadFunction(dirname + pathStart), err => {
         if (err) throw err;
         console.log(`Renamed ${filename} to ${onFileReadFunction(dirname + pathStart)}`);
     });
 });
開發者ID:EmmaRamirez,項目名稱:nuzlocke-generator,代碼行數:9,代碼來源:massRename.ts

示例9:

    fs.stat(oldDirPath, (err, stats) => {
      const dirPath = path.join(this.server.projectPath, `assets/${this.server.data.entries.getStoragePathFromId(id)}`);

      if (stats == null) asset.load(dirPath);
      else {
        fs.rename(oldDirPath, dirPath, (err) => {
          if (err != null) throw err;
          asset.load(dirPath);
        });
      }
    });
開發者ID:AndreLewin,項目名稱:superpowers-core,代碼行數:11,代碼來源:Assets.ts

示例10: uploadFile

 async uploadFile(ctx: k.IContext, next) {
     let file = ctx.req['file'];
     let originalname = path.parse(file.originalname);
     let newname = originalname.name + '.' + UUID.raw() + originalname.ext;
     let filepath = file.path;
     let newpath = 'files/' + newname;
     fs.rename(filepath, newpath);
     ctx.set('Content-Type', 'application/json');
     ctx.set('status', 200);
     ctx.body = { fileUri: newpath };
 }
開發者ID:wangxin0709,項目名稱:csc-scms-node-koa,代碼行數:11,代碼來源:file-controller.ts


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