<commit_before># wFiles

Files manipulation library of middle level. Module offers several implementations  of single interface, called "FileProvider's" to perform file operations on different type of resources.

### Avaible operations:
* File read/write operations.
* Creating read/write steams.
* Operations with file [stats](https://nodejs.org/api/fs.html#fs_class_fs_stats) object.
* File create,delete,rename,copy operations.
* Making [soft](https://en.wikipedia.org/wiki/Symbolic_link)/[hard](https://en.wikipedia.org/wiki/Hard_link) links.

### Installation
```terminal
npm install wFiles
```



### FileProvider.HardDrive
Allows files manipulations on local drive.

###### Declaration
```javascript
var _ = wTools;
var provider = _.FileProvider.HardDrive();
```


### FileProvider.SimpleStructure
Allows file manipulations on `filesTree` - object based on some folders/files tree, where folders are nested objects with same depth level as in real folder and contains some files that are properties with corresponding names and file content as a values.

###### Structure example:
```javascript
var tree =
{
 "some_dir" :
 {
   'some_file.txt' : "content",
   'empty_dir' : {}
 }
}
```
###### Declaration
```javascript
var _ = wTools;
var provider = _.FileProvider.SimpleStructure({ filesTree : tree });
```
<!-- ###### FileProvider.Url desc here -->
### Usage:

###### Example #1
```javascript
/*Read file synchronously*/
var data = provider.fileReadAct({ pathFile : 'my_file', sync : 1 });
console.log( data );

/*Read file asynchronously*/
provider.fileReadAct({ pathFile : 'my_file' })
.got( function( err, data )
{
  if( err )
  throw err;
  console.log( data );  
});
```
###### Example #2
```javascript
/*Write to file synchronously*/
provider.fileWriteAct({ pathFile : 'my_file', data : 'some data' })

/*Write to file asynchronously*/
provider.fileWriteAct({ pathFile : 'my_file', data : 'some data', sync : 0 })
.got( function( err )
{
  if( err )
  throw err;
  console.log( 'Success' );  
});
```
###### Example #3
```javascript
/*Create dir synchronously*/
provider.directoryMakeAct( 'my_dir' );

/*Write to file asynchronously*/
provider.directoryMakeAct({ pathFile : 'a', sync : 0 })
.got( function( err )
{
  if( err )
  throw err;
  /*some code after dir creation*/
});
```<commit_msg>readme update<commit_after># wFiles

Files manipulation library of middle level. Module offers several implementations  of single interface, called "FileProvider's" to perform file operations on different type of resources.

### Avaible operations:
* File read/write operations.
* Creating read/write steams.
* Operations with file [stats](https://nodejs.org/api/fs.html#fs_class_fs_stats) object.
* File create,delete,rename,copy operations.
* Making [soft](https://en.wikipedia.org/wiki/Symbolic_link)/[hard](https://en.wikipedia.org/wiki/Hard_link) links.

### Installation
```terminal
npm install wFiles
```

### FileProvider.HardDrive
Allows files manipulations on local drive.

###### Declaration
```javascript
var _ = wTools;
var provider = _.FileProvider.HardDrive();
```

### FileProvider.SimpleStructure
Allows file manipulations on `filesTree` - object based on some folders/files tree, where folders are nested objects with same depth level as in real folder and contains some files that are properties with corresponding names and file content as a values.

###### Structure example:
```javascript
var tree =
{
 "some_dir" :
 {
   'some_file.txt' : "content",
   'empty_dir' : {}
 }
}
```
###### Declaration
```javascript
var _ = wTools;
var provider = _.FileProvider.SimpleStructure({ filesTree : tree });
```
<!-- ###### FileProvider.Url desc here -->
### Usage:

###### Example #1
```javascript
/*Read file synchronously*/
var data = provider.fileReadAct
({
  pathFile : 'my_file',
  sync : 1
});
console.log( data );

/*Read file asynchronously*/
provider.fileReadAct({ pathFile : 'my_file' })
.got( function( err, data )
{
  if( err )
  throw err;
  console.log( data );  
});
```
###### Example #2
```javascript
/*Write to file synchronously*/
provider.fileWriteAct
({
  pathFile : 'my_file',
  data : 'some data'
})

/*Write to file asynchronously*/
provider.fileWriteAct
({
  pathFile : 'my_file',
  data : 'some data',
  sync : 0
})
.got( function( err )
{
  if( err )
  throw err;
  console.log( 'Success' );  
});
```
###### Example #3
```javascript
/*Create dir synchronously*/
provider.directoryMakeAct( 'my_dir' );

/*Create dir asynchronously*/
provider.directoryMakeAct
({
   pathFile : 'a',
   sync : 0
 })
.got( function( err )
{
  if( err )
  throw err;
  /*some code after dir creation*/
});
```
###### Example #4
```javascript
/*Getting file stats object sync*/
/*error throwing is disabled by default, use throwing : 1 to turn on*/
var stats = provider.fileStatAct( 'my_dir' );
if( stats )
console.log( stats );

/*async*/
provider.fileStatAct
({
   pathFile : 'my_dir',
   throwing : 1,
   sync : 0
})
.got( function( err, stats )
{
  if( err )
  throw err;
  console.log( stats );
});
```
###### Example #5
```javascript
/*Copy file sync*/
provider.fileCopyAct
({  
  pathDst : 'my_file2',
  pathSrc : 'my_file'
});

```
{'fraction_non_alphanumeric': 0.15795586527293845, 'fraction_numerical': 0.003484320557491289, 'mean_word_length': 4.359958506224066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2157886', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1552, 'n_words': 499}