qLibc

Functions
qcount.c File Reference

Counter file handling APIs. More...

Go to the source code of this file.

## Functions
int64_t | qcount_read (const char *filepath)
| Read counter(integer) from file with advisory file locking.
bool | qcount_save (const char *filepath, int64_t number)
| Save counter(integer) to file with advisory file locking.
int64_t | qcount_update (const char *filepath, int64_t number)
| Increases(or decrease) the counter value as much as specified number with advisory file locking.

## Detailed Description

Counter file handling APIs.

Definition in file qcount.c.

## Function Documentation

## ◆ qcount_read()

int64_t qcount_read | ( | const char * | filepath | ) |

Read counter(integer) from file with advisory file locking.

Parameters

  filepath | file path

Returns
  counter value readed from file. in case of failure, returns 0.

qcount_save("number.dat", 75);
int count = qcount_read("number.dat");
qcount_save
bool qcount_save(const char *filepath, int64_t number)
Save counter(integer) to file with advisory file locking.
Definition qcount.c:95
qcount_read
int64_t qcount_read(const char *filepath)
Read counter(integer) from file with advisory file locking.
Definition qcount.c:65
---- number.dat ----
75
--------------------

Definition at line 65 of file qcount.c.

## ◆ qcount_save()

bool qcount_save | ( | const char * | filepath,
|  | int64_t | number
| ) |  |

Save counter(integer) to file with advisory file locking.

Parameters

  filepath | file path
  number | counter integer value

Returns
  true if successful, otherwise returns false.

qcount_save("number.dat", 75);

Definition at line 95 of file qcount.c.

## ◆ qcount_update()

int64_t qcount_update | ( | const char * | filepath,
|  | int64_t | number
| ) |  |

Increases(or decrease) the counter value as much as specified number with advisory file locking.

Parameters

  filepath | file path
  number | how much increase or decrease

Returns
  updated counter value. in case of failure, returns 0.

int count;
count = qcount_update("number.dat", -3);
qcount_update
int64_t qcount_update(const char *filepath, int64_t number)
Increases(or decrease) the counter value as much as specified number with advisory file locking.
Definition qcount.c:124

Definition at line 124 of file qcount.c.