Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1027380 // cleanFluidTextFile

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (5764L) is out of date.

1  
// returns true if file was changed
2  
sbool cleanFluidTextFile(File f, O... _) {
3  
  optPar bool withBackup = true;
4  
  optPar bool verbose;
5  
  new CleanFluidTextFile cleaner;
6  
  cleaner.verbose = verbose;
7  
  {
8  
    temp Reader reader = utf8reader(f);
9  
    cleaner.reader = reader;
10  
    cleaner.read();
11  
  }
12  
  new StringWriter writer;
13  
  cleaner.writer = writer;
14  
  cleaner.write();
15  
  S out = str(writer);
16  
  if (eq(loadTextFile(f), out)) false;
17  
  if (withBackup)
18  
    print("Backed file up to " + renameFileToSomeBackupName(f, "fluidClean"));
19  
  saveTextFile(f, out);
20  
  true;
21  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027380
Snippet name: cleanFluidTextFile
Eternal ID of this version: #1027380/8
Text MD5: bb8c727e1ea2c0ae7648128f873c630d
Author: stefan
Category: javax / fluid text files
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-15 17:06:53
Source code size: 580 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 206 / 304
Version history: 7 change(s)
Referenced in: [show references]