当前位置: 首页>>代码示例>>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;未经允许,请勿转载。