-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscore.c
More file actions
36 lines (31 loc) · 752 Bytes
/
Copy pathscore.c
File metadata and controls
36 lines (31 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
** score.c for tetris in /home/thibrex/Dropbox/delivery/PSU/PSU_2016_tetris
**
** Made by Thibaut Cornolti
** Login <thibaut.cornolti@epitech.eu>
**
** Started on Fri Mar 17 13:11:03 2017 Thibaut Cornolti
** Last update Sun Mar 19 16:45:14 2017 Thibaut Cornolti
*/
#include <fcntl.h>
#include <unistd.h>
#include "tetris.h"
void get_high_score(t_game *game)
{
int fd;
if ((fd = open(HIGH_SCORE_F, O_RDONLY)) <= 0)
return ;
read(fd, &(game->high_score), sizeof(int));
close(fd);
}
void set_high_score(t_game *game)
{
int fd;
if (game->high_score >= game->score)
return ;
if ((fd = open(HIGH_SCORE_F,
O_RDWR | O_CREAT | O_TRUNC, 0644)) <= 0)
return ;
write(fd, &(game->score), sizeof(int));
close(fd);
}