Removed some old DOS code, unified (for gcc) the handling of file paths.
Probably fixed some linux issues there. Fixed the filename search by typing in Save/load. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@196 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
16f642c689
commit
dd984538bf
@ -1,6 +1,6 @@
|
|||||||
main.o: main.c const.h struct.h global.h loadsave.h graph.h divers.h \
|
main.o: main.c const.h struct.h global.h loadsave.h graph.h divers.h \
|
||||||
init.h boutons.h moteur.h pages.h files.h sdlscreen.h erreurs.h \
|
init.h boutons.h moteur.h pages.h files.h sdlscreen.h erreurs.h \
|
||||||
readini.h saveini.h linux.h
|
readini.h saveini.h linux.h io.h
|
||||||
init.o: init.c const.h struct.h global.h loadsave.h graph.h boutons.h \
|
init.o: init.c const.h struct.h global.h loadsave.h graph.h boutons.h \
|
||||||
palette.h aide.h operatio.h divers.h erreurs.h clavier.h io.h
|
palette.h aide.h operatio.h divers.h erreurs.h clavier.h io.h
|
||||||
graph.o: graph.c sdlscreen.h struct.h const.h graph.h divers.h moteur.h \
|
graph.o: graph.c sdlscreen.h struct.h const.h graph.h divers.h moteur.h \
|
||||||
@ -13,7 +13,7 @@ special.o: special.c const.h struct.h global.h loadsave.h graph.h \
|
|||||||
moteur.h
|
moteur.h
|
||||||
boutons.o: boutons.c const.h struct.h global.h loadsave.h divers.h \
|
boutons.o: boutons.c const.h struct.h global.h loadsave.h divers.h \
|
||||||
graph.h moteur.h readline.h files.h init.h boutons.h operatio.h pages.h \
|
graph.h moteur.h readline.h files.h init.h boutons.h operatio.h pages.h \
|
||||||
erreurs.h readini.h saveini.h shade.h
|
erreurs.h readini.h saveini.h shade.h io.h
|
||||||
palette.o: palette.c const.h struct.h global.h loadsave.h divers.h \
|
palette.o: palette.c const.h struct.h global.h loadsave.h divers.h \
|
||||||
graph.h moteur.h readline.h boutons.h pages.h
|
graph.h moteur.h readline.h boutons.h pages.h
|
||||||
aide.o: aide.c const.h struct.h global.h loadsave.h divers.h graph.h \
|
aide.o: aide.c const.h struct.h global.h loadsave.h divers.h graph.h \
|
||||||
@ -39,4 +39,4 @@ saveini.o: saveini.c const.h global.h struct.h loadsave.h readini.h \
|
|||||||
shade.o: shade.c global.h struct.h const.h loadsave.h graph.h moteur.h \
|
shade.o: shade.c global.h struct.h const.h loadsave.h graph.h moteur.h \
|
||||||
divers.h readline.h
|
divers.h readline.h
|
||||||
clavier.o: clavier.c global.h struct.h const.h loadsave.h
|
clavier.o: clavier.c global.h struct.h const.h loadsave.h
|
||||||
io.o: io.c struct.h const.h
|
io.o: io.c struct.h const.h io.h
|
||||||
|
|||||||
51
boutons.c
51
boutons.c
@ -23,6 +23,7 @@
|
|||||||
#include "readini.h"
|
#include "readini.h"
|
||||||
#include "saveini.h"
|
#include "saveini.h"
|
||||||
#include "shade.h"
|
#include "shade.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
#ifdef __WATCOMC__
|
#ifdef __WATCOMC__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -2103,7 +2104,7 @@ void Print_repertoire_courant(void)
|
|||||||
// Ensuite, on cherche un endroit à partir duquel on pourrait loger tout
|
// Ensuite, on cherche un endroit à partir duquel on pourrait loger tout
|
||||||
// le reste de la chaine (Ouaaaaaah!!! Vachement fort le mec!!)
|
// le reste de la chaine (Ouaaaaaah!!! Vachement fort le mec!!)
|
||||||
for (Indice++;Indice<Longueur;Indice++)
|
for (Indice++;Indice<Longueur;Indice++)
|
||||||
if ( (Principal_Repertoire_courant[Indice]=='\\') &&
|
if ( (Principal_Repertoire_courant[Indice]==SEPARATEUR_CHEMIN[0]) &&
|
||||||
(Longueur-Indice<=TAILLE_MAXI_PATH-6) )
|
(Longueur-Indice<=TAILLE_MAXI_PATH-6) )
|
||||||
{
|
{
|
||||||
// Ouf: on vient de trouver un endroit dans la chaîne à partir duquel
|
// Ouf: on vient de trouver un endroit dans la chaîne à partir duquel
|
||||||
@ -2239,9 +2240,6 @@ void Placer_barre_de_selection_sur(char * Nom)
|
|||||||
char FFF_Meilleur_nom[TAILLE_CHEMIN_FICHIER];
|
char FFF_Meilleur_nom[TAILLE_CHEMIN_FICHIER];
|
||||||
char * Nom_correspondant_le_mieux_a(char * Nom)
|
char * Nom_correspondant_le_mieux_a(char * Nom)
|
||||||
{
|
{
|
||||||
char Nom_courant[TAILLE_CHEMIN_FICHIER];
|
|
||||||
char * Pointeur1;
|
|
||||||
char * Pointeur2;
|
|
||||||
char * Pointeur_Meilleur_nom;
|
char * Pointeur_Meilleur_nom;
|
||||||
struct Element_de_liste_de_fileselect * Element_courant;
|
struct Element_de_liste_de_fileselect * Element_courant;
|
||||||
byte Lettres_identiques=0;
|
byte Lettres_identiques=0;
|
||||||
@ -2255,18 +2253,12 @@ char * Nom_correspondant_le_mieux_a(char * Nom)
|
|||||||
if ( (!Config.Find_file_fast)
|
if ( (!Config.Find_file_fast)
|
||||||
|| (Config.Find_file_fast==(Element_courant->Type+1)) )
|
|| (Config.Find_file_fast==(Element_courant->Type+1)) )
|
||||||
{
|
{
|
||||||
// On copie le nom de la liste en cours de traitement dans Nom_courant
|
|
||||||
// tout en le remettant sous forme normale.
|
|
||||||
for (Pointeur1=Element_courant->NomComplet,Pointeur2=Nom_courant;*Pointeur1;Pointeur1++)
|
|
||||||
if (*Pointeur1!=' ')
|
|
||||||
*(Pointeur2++)=*Pointeur1;
|
|
||||||
*Pointeur2=0;
|
|
||||||
// On compare et si c'est mieux, on stocke dans Meilleur_nom
|
// On compare et si c'est mieux, on stocke dans Meilleur_nom
|
||||||
for (Compteur=0; tolower(Nom_courant[Compteur])==tolower(Nom[Compteur]); Compteur++);
|
for (Compteur=0; tolower(Element_courant->NomComplet[Compteur])==tolower(Nom[Compteur]); Compteur++);
|
||||||
if (Compteur>Lettres_identiques)
|
if (Compteur>Lettres_identiques)
|
||||||
{
|
{
|
||||||
Lettres_identiques=Compteur;
|
Lettres_identiques=Compteur;
|
||||||
strcpy(FFF_Meilleur_nom,Nom_courant);
|
strcpy(FFF_Meilleur_nom,Element_courant->NomComplet);
|
||||||
Pointeur_Meilleur_nom=Element_courant->NomComplet;
|
Pointeur_Meilleur_nom=Element_courant->NomComplet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2390,16 +2382,20 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// On prend bien soin de passer dans le répertoire courant (le bon qui faut! Oui madame!)
|
// On prend bien soin de passer dans le répertoire courant (le bon qui faut! Oui madame!)
|
||||||
chdir(Principal_Repertoire_courant);
|
if (Load)
|
||||||
/*_dos_setdrive(Principal_Repertoire_courant[0]-64,&Bidon);*/
|
{
|
||||||
Determiner_repertoire_courant();
|
chdir(Principal_Repertoire_courant);
|
||||||
|
Determiner_repertoire_courant();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chdir(Principal_Repertoire_fichier);
|
||||||
|
Determiner_repertoire_courant();
|
||||||
|
}
|
||||||
|
|
||||||
// Affichage des premiers fichiers visibles:
|
// Affichage des premiers fichiers visibles:
|
||||||
Relire_liste_fichiers(Principal_Format,Principal_File_list_Position,Principal_File_list_Decalage,Scroller_de_fichiers);
|
Relire_liste_fichiers(Principal_Format,Principal_File_list_Position,Principal_File_list_Decalage,Scroller_de_fichiers);
|
||||||
|
|
||||||
// Je n'efface pas cette partie parce que l'idée n'était pas mauvaise mais
|
|
||||||
// ça chie un maximum alors autant ne pas trop compliquer les choses...
|
|
||||||
/*
|
|
||||||
if (!Load)
|
if (!Load)
|
||||||
{
|
{
|
||||||
// On initialise le nom de fichier à celui en cours et non pas celui sous
|
// On initialise le nom de fichier à celui en cours et non pas celui sous
|
||||||
@ -2408,7 +2404,6 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
|||||||
// On affiche le nouveau nom de fichier
|
// On affiche le nouveau nom de fichier
|
||||||
Print_Nom_fichier_dans_selecteur();
|
Print_Nom_fichier_dans_selecteur();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
Pixel_de_chargement=Pixel_Chargement_dans_preview;
|
Pixel_de_chargement=Pixel_Chargement_dans_preview;
|
||||||
Nouvelle_preview=1;
|
Nouvelle_preview=1;
|
||||||
@ -2679,11 +2674,10 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
|||||||
Temp=strlen(Fichier_recherche);
|
Temp=strlen(Fichier_recherche);
|
||||||
if (Touche_ANSI>= ' ' && Touche_ANSI < 255 && Temp<50)
|
if (Touche_ANSI>= ' ' && Touche_ANSI < 255 && Temp<50)
|
||||||
{
|
{
|
||||||
Fichier_recherche[Temp]=toupper(Touche_ANSI);
|
Fichier_recherche[Temp]=Touche_ANSI;
|
||||||
Fichier_recherche[Temp+1]=0;
|
Fichier_recherche[Temp+1]='\0';
|
||||||
Fichier_le_plus_ressemblant=Nom_correspondant_le_mieux_a(Fichier_recherche);
|
Fichier_le_plus_ressemblant=Nom_correspondant_le_mieux_a(Fichier_recherche);
|
||||||
if ( (Fichier_le_plus_ressemblant)
|
if ( (Fichier_le_plus_ressemblant) )
|
||||||
&& (!memcmp(Fichier_recherche,FFF_Meilleur_nom,Temp+1)) )
|
|
||||||
{
|
{
|
||||||
Temp=Principal_File_list_Position+Principal_File_list_Decalage;
|
Temp=Principal_File_list_Position+Principal_File_list_Decalage;
|
||||||
Effacer_curseur();
|
Effacer_curseur();
|
||||||
@ -2694,7 +2688,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
|||||||
Nouvelle_preview=1;
|
Nouvelle_preview=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Fichier_recherche[Temp]=0;
|
*Fichier_recherche=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2715,10 +2709,9 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
|||||||
strcpy(Repertoire_precedent,Nom_formate(".."));
|
strcpy(Repertoire_precedent,Nom_formate(".."));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Temp=strlen(Principal_Repertoire_courant);
|
strcpy(Repertoire_precedent,
|
||||||
(Temp>0) && (Principal_Repertoire_courant[Temp-1]!='\\');
|
Nom_formate(Position_dernier_slash(Principal_Repertoire_courant))
|
||||||
Temp--);
|
);
|
||||||
strcpy(Repertoire_precedent,Nom_formate(Principal_Repertoire_courant+Temp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On doit rentrer dans le répertoire:
|
// On doit rentrer dans le répertoire:
|
||||||
|
|||||||
39
divers.c
39
divers.c
@ -578,45 +578,6 @@ byte Lit_pixel_dans_ecran_backup (word X,word Y)
|
|||||||
return *(Ecran_backup + X + Principal_Largeur_image * Y);
|
return *(Ecran_backup + X + Principal_Largeur_image * Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte Type_de_lecteur_de_disquette(byte Numero_de_lecteur)
|
|
||||||
// Numero_de_lecteur compris entre 0 et 3 (4 lecteurs de disquettes)
|
|
||||||
//
|
|
||||||
// Résultat = 0 : Pas de lecteur
|
|
||||||
// 1 : Lecteur 360 Ko
|
|
||||||
// 2 : Lecteur 1.2 Mo
|
|
||||||
// 3 : Lecteur 720 Ko
|
|
||||||
// 4 : Lecteur 1.4 Mo
|
|
||||||
// 5 : Lecteur 2.8 Mo (??? pas sur ???)
|
|
||||||
// 6 : Lecteur 2.8 Mo
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte Disk_map(byte Numero_de_lecteur)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte Disque_dur_present(byte Numero_de_disque)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte Lecteur_CDROM_present(byte Numero_de_lecteur)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
long Freespace(byte Numero_de_lecteur)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Les images ILBM sont stockés en bitplanes donc on doit trifouiller les bits pour
|
// Les images ILBM sont stockés en bitplanes donc on doit trifouiller les bits pour
|
||||||
// en faire du chunky
|
// en faire du chunky
|
||||||
|
|
||||||
|
|||||||
46
divers.h
46
divers.h
@ -35,52 +35,6 @@ byte Lit_pixel_dans_ecran_backup (word X,word Y);
|
|||||||
byte Lit_pixel_dans_ecran_feedback (word X,word Y);
|
byte Lit_pixel_dans_ecran_feedback (word X,word Y);
|
||||||
byte Lit_pixel_dans_brosse (word X,word Y);
|
byte Lit_pixel_dans_brosse (word X,word Y);
|
||||||
|
|
||||||
long Freespace(byte Numero_de_lecteur);
|
|
||||||
// Numero_de_lecteur = 0 : Disque courant
|
|
||||||
// 1 : lecteur A:
|
|
||||||
// 2 : lecteur B:
|
|
||||||
// 3 : lecteur C:
|
|
||||||
// ... : ...
|
|
||||||
//
|
|
||||||
// Résultat = -1 si lecteur invalide, taille disponible sinon
|
|
||||||
|
|
||||||
byte Type_de_lecteur_de_disquette(byte Numero_de_lecteur);
|
|
||||||
// Numero_de_lecteur compris entre 0 et 3 (4 lecteurs de disquettes)
|
|
||||||
//
|
|
||||||
// Résultat = 0 : Pas de lecteur
|
|
||||||
// 1 : Lecteur 360 Ko
|
|
||||||
// 2 : Lecteur 1.2 Mo
|
|
||||||
// 3 : Lecteur 720 Ko
|
|
||||||
// 4 : Lecteur 1.4 Mo
|
|
||||||
// 5 : Lecteur 2.8 Mo (??? pas sur ???)
|
|
||||||
// 6 : Lecteur 2.8 Mo
|
|
||||||
|
|
||||||
byte Disk_map(byte Numero_de_lecteur);
|
|
||||||
// Renseigne sur la lettre logique d'un lecteur
|
|
||||||
// (utile pour tester si un lecteur de disquette est A: ou B: aux yeux du DOS)
|
|
||||||
//
|
|
||||||
// Entrée: Octet = n° du lecteur (1=A, 2=B ...)
|
|
||||||
//
|
|
||||||
// Sortie: Octet = 0FFh : Pas de lecteur (???)
|
|
||||||
// sinon: numéro représenatan la lettre logique du lecteur
|
|
||||||
// (commence à 1)
|
|
||||||
|
|
||||||
byte Disque_dur_present(byte Numero_de_disque);
|
|
||||||
// Numero_de_disque = 0:C, 1:D, 2:E, ...
|
|
||||||
//
|
|
||||||
// Résultat = 0 : Pas de disque dur présent
|
|
||||||
// 1 : Disque dur présent
|
|
||||||
|
|
||||||
byte Lecteur_CDROM_present(byte Numero_de_lecteur);
|
|
||||||
// Numero_de_lecteur = 0 : lecteur A:
|
|
||||||
// 1 : lecteur B:
|
|
||||||
// 2 : lecteur C:
|
|
||||||
// ... : ...
|
|
||||||
//
|
|
||||||
// Résultat = 0 : Pas de lecteur CD-ROM présent
|
|
||||||
// 1 : Lecteur CD-ROM présent
|
|
||||||
|
|
||||||
|
|
||||||
void Ellipse_Calculer_limites(short Rayon_horizontal,short Rayon_vertical);
|
void Ellipse_Calculer_limites(short Rayon_horizontal,short Rayon_vertical);
|
||||||
// Calcule les valeurs suivantes en fonction des deux paramètres:
|
// Calcule les valeurs suivantes en fonction des deux paramètres:
|
||||||
//
|
//
|
||||||
|
|||||||
38
init.c
38
init.c
@ -31,13 +31,7 @@
|
|||||||
// Chercher le répertoire contenant GFX2.EXE
|
// Chercher le répertoire contenant GFX2.EXE
|
||||||
void Chercher_repertoire_du_programme(char * Chaine)
|
void Chercher_repertoire_du_programme(char * Chaine)
|
||||||
{
|
{
|
||||||
#ifdef __WATCOMC__
|
Extraire_chemin(Repertoire_du_programme, Chaine);
|
||||||
GetCurrentDirectory(255,Repertoire_du_programme);
|
|
||||||
strcat(Repertoire_du_programme,"\\");
|
|
||||||
#else
|
|
||||||
puts("Chercher_repertoire_du_programme: implémentation incomplète");
|
|
||||||
Repertoire_du_programme[0]=0; //On va travailler dans le dossier courant ...
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -202,21 +196,23 @@ void Charger_DAT(void)
|
|||||||
|
|
||||||
strcpy(Nom_du_fichier,Repertoire_du_programme);
|
strcpy(Nom_du_fichier,Repertoire_du_programme);
|
||||||
strcat(Nom_du_fichier,"gfx2.dat");
|
strcat(Nom_du_fichier,"gfx2.dat");
|
||||||
|
|
||||||
if(stat(Nom_du_fichier,&Informations_Fichier))
|
if(stat(Nom_du_fichier,&Informations_Fichier))
|
||||||
switch errno
|
{
|
||||||
{
|
switch errno
|
||||||
case EACCES: puts("La permission de parcours est refusée pour un des répertoires contenu dans le chemin path."); break;
|
{
|
||||||
case EBADF: puts("filedes est un mauvais descripteur."); break;
|
case EACCES: puts("La permission de parcours est refusée pour un des répertoires contenu dans le chemin path."); break;
|
||||||
case EFAULT: puts("Un pointeur se trouve en dehors de l'espace d'adressage."); break;
|
case EBADF: puts("filedes est un mauvais descripteur."); break;
|
||||||
case ENAMETOOLONG: puts("Nom de fichier trop long."); break;
|
case EFAULT: puts("Un pointeur se trouve en dehors de l'espace d'adressage."); break;
|
||||||
case ENOENT: puts("Un composant du chemin path n'existe pas, ou il s'agit d'une chaîne vide."); break;
|
case ENAMETOOLONG: puts("Nom de fichier trop long."); break;
|
||||||
case ENOMEM: puts("Pas assez de mémoire pour le noyau."); break;
|
case ENOENT: puts("Un composant du chemin path n'existe pas, ou il s'agit d'une chaîne vide."); break;
|
||||||
case ENOTDIR: puts("Un composant du chemin d'accès n'est pas un répertoire."); break;
|
case ENOMEM: puts("Pas assez de mémoire pour le noyau."); break;
|
||||||
#ifdef __linux__
|
case ENOTDIR: puts("Un composant du chemin d'accès n'est pas un répertoire."); break;
|
||||||
case ELOOP: puts("Trop de liens symboliques rencontrés dans le chemin d'accès."); break;
|
#ifdef __linux__
|
||||||
#endif
|
case ELOOP: puts("Trop de liens symboliques rencontrés dans le chemin d'accès."); break;
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Taille_fichier=Informations_Fichier.st_size;
|
Taille_fichier=Informations_Fichier.st_size;
|
||||||
if (Taille_fichier<DAT_DEBUT_INI_PAR_DEFAUT)
|
if (Taille_fichier<DAT_DEBUT_INI_PAR_DEFAUT)
|
||||||
|
|||||||
45
io.c
45
io.c
@ -3,7 +3,9 @@
|
|||||||
// little-endian.
|
// little-endian.
|
||||||
|
|
||||||
#include <SDL/SDL_endian.h>
|
#include <SDL/SDL_endian.h>
|
||||||
|
#include <string.h>
|
||||||
#include "struct.h"
|
#include "struct.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
word endian_magic16(word x)
|
word endian_magic16(word x)
|
||||||
{
|
{
|
||||||
@ -13,7 +15,7 @@ word endian_magic16(word x)
|
|||||||
return SDL_Swap16(x);
|
return SDL_Swap16(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
word endian_magic32(word x)
|
dword endian_magic32(dword x)
|
||||||
{
|
{
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
return x;
|
return x;
|
||||||
@ -128,3 +130,44 @@ int write_dword_be(FILE *Fichier, dword Mot)
|
|||||||
#endif
|
#endif
|
||||||
return fwrite(&Mot, 1, sizeof(dword), Fichier) == sizeof(dword);
|
return fwrite(&Mot, 1, sizeof(dword), Fichier) == sizeof(dword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Détermine la position du dernier '/' ou '\\' dans une chaine,
|
||||||
|
// typiquement pour séparer le nom de fichier d'un chemin.
|
||||||
|
// Attention, sous Windows, il faut s'attendre aux deux car
|
||||||
|
// par exemple un programme lancé sous GDB aura comme argv[0]:
|
||||||
|
// d:\Data\C\GFX2\grafx2/grafx2.exe
|
||||||
|
char * Position_dernier_slash(const char * Chaine)
|
||||||
|
{
|
||||||
|
const char * Position = NULL;
|
||||||
|
for (; *Chaine != '\0'; Chaine++)
|
||||||
|
if (*Chaine == SEPARATEUR_CHEMIN[0]
|
||||||
|
#ifdef __WIN32__
|
||||||
|
|| *Chaine == '/'
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
Position = Chaine;
|
||||||
|
return (char *)Position;
|
||||||
|
}
|
||||||
|
// Récupère la partie "nom de fichier seul" d'un chemin
|
||||||
|
void Extraire_nom_fichier(char *Destination, const char *Source)
|
||||||
|
{
|
||||||
|
const char * Position = Position_dernier_slash(Source);
|
||||||
|
|
||||||
|
if (Position)
|
||||||
|
strcpy(Destination,Position+1);
|
||||||
|
else
|
||||||
|
strcpy(Destination,Source);
|
||||||
|
}
|
||||||
|
// Récupère la partie "répertoire+/" d'un chemin.
|
||||||
|
void Extraire_chemin(char *Destination, const char *Source)
|
||||||
|
{
|
||||||
|
char * Position;
|
||||||
|
|
||||||
|
strcpy(Destination,Source);
|
||||||
|
Position = Position_dernier_slash(Destination);
|
||||||
|
if (Position)
|
||||||
|
*(Position+1) = '\0';
|
||||||
|
else
|
||||||
|
strcat(Destination, SEPARATEUR_CHEMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
11
io.h
11
io.h
@ -17,3 +17,14 @@ int read_word_be(FILE *Fichier, word *Dest);
|
|||||||
int write_word_be(FILE *Fichier, word Mot);
|
int write_word_be(FILE *Fichier, word Mot);
|
||||||
int read_dword_be(FILE *Fichier, dword *Dest);
|
int read_dword_be(FILE *Fichier, dword *Dest);
|
||||||
int write_dword_be(FILE *Fichier, dword Mot);
|
int write_dword_be(FILE *Fichier, dword Mot);
|
||||||
|
|
||||||
|
void Extraire_nom_fichier(char *Destination, const char *Source);
|
||||||
|
void Extraire_chemin(char *Destination, const char *Source);
|
||||||
|
|
||||||
|
char * Position_dernier_slash(const char * Chaine);
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#define SEPARATEUR_CHEMIN "/"
|
||||||
|
#else
|
||||||
|
#define SEPARATEUR_CHEMIN "\\"
|
||||||
|
#endif
|
||||||
|
|||||||
16
linux.c
16
linux.c
@ -5,22 +5,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
void _splitpath(char* Buffer, char* Chemin, char* Nom_Fichier)
|
|
||||||
{
|
|
||||||
int i=0, Position_Du_Dernier_Slash=0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Chemin[i]=Buffer[i];
|
|
||||||
if (Buffer[i]=='/')
|
|
||||||
Position_Du_Dernier_Slash=i;
|
|
||||||
i++;
|
|
||||||
}while (Buffer[i]!=0);
|
|
||||||
|
|
||||||
i=Position_Du_Dernier_Slash+1;
|
|
||||||
Chemin[i]=0;
|
|
||||||
strcpy(Nom_Fichier,Buffer+i);
|
|
||||||
}
|
|
||||||
|
|
||||||
int filelength(int fichier)
|
int filelength(int fichier)
|
||||||
{
|
{
|
||||||
struct stat infos_fichier;
|
struct stat infos_fichier;
|
||||||
|
|||||||
3
linux.h
3
linux.h
@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
void _splitpath(char* Buffer, char* Chemin, char* Nom_Fichier);
|
|
||||||
/* Sépare dans la chaîne passée dans Buffer le chemin d'accès du nom de fichier */
|
|
||||||
|
|
||||||
struct find_t {
|
struct find_t {
|
||||||
unsigned char attrib;
|
unsigned char attrib;
|
||||||
char name[256];
|
char name[256];
|
||||||
|
|||||||
40
main.c
40
main.c
@ -24,6 +24,7 @@
|
|||||||
#include "readini.h"
|
#include "readini.h"
|
||||||
#include "saveini.h"
|
#include "saveini.h"
|
||||||
#include "linux.h"
|
#include "linux.h"
|
||||||
|
#include "io.h"
|
||||||
|
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -215,34 +216,17 @@ void Analyse_de_la_ligne_de_commande(int argc,char * argv[])
|
|||||||
// On récupère le chemin complet du paramètre
|
// On récupère le chemin complet du paramètre
|
||||||
// Et on découpe ce chemin en répertoire(path) + fichier(.ext)
|
// Et on découpe ce chemin en répertoire(path) + fichier(.ext)
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
Buffer=realpath(argv[1],NULL);
|
Buffer=realpath(argv[1],NULL);
|
||||||
_splitpath(Buffer,Principal_Repertoire_fichier,Principal_Nom_fichier);
|
|
||||||
#else
|
#else
|
||||||
Buffer = malloc(TAILLE_CHEMIN_FICHIER);
|
Buffer = malloc(TAILLE_CHEMIN_FICHIER);
|
||||||
_fullpath(Buffer,argv[1],TAILLE_CHEMIN_FICHIER);
|
_fullpath(Buffer,argv[1],TAILLE_CHEMIN_FICHIER);
|
||||||
{
|
|
||||||
// Découpage du nom canonique de fichier en chemin + nom.
|
|
||||||
// On croirait que c'est du classique pour la LibC, mais non...
|
|
||||||
int i;
|
|
||||||
int PosDernierSeparateur = 0;
|
|
||||||
for (i=0; Buffer[i]!='\0'; i++)
|
|
||||||
{
|
|
||||||
Principal_Repertoire_fichier[i] = Buffer[i];
|
|
||||||
if (Buffer[i]=='\\')
|
|
||||||
PosDernierSeparateur = i;
|
|
||||||
}
|
|
||||||
Principal_Repertoire_fichier[PosDernierSeparateur]='\0';
|
|
||||||
for (i=0; Buffer[PosDernierSeparateur + i + 1]!='\0'; i++)
|
|
||||||
{
|
|
||||||
Principal_Nom_fichier[i] = Buffer[PosDernierSeparateur + i + 1];
|
|
||||||
}
|
|
||||||
Principal_Nom_fichier[i]='\0';
|
|
||||||
|
|
||||||
}
|
|
||||||
free(Buffer);
|
|
||||||
#endif
|
#endif
|
||||||
|
Extraire_chemin(Principal_Repertoire_fichier, Buffer);
|
||||||
// chdir(Principal_Repertoire_fichier);
|
Extraire_nom_fichier(Principal_Nom_fichier, Buffer);
|
||||||
|
#ifndef __linux__
|
||||||
|
free(Buffer);
|
||||||
|
#endif
|
||||||
|
chdir(Principal_Repertoire_fichier);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -309,6 +293,7 @@ void Initialisation_du_programme(int argc,char * argv[])
|
|||||||
|
|
||||||
// On détermine dès le départ où se trouve le fichier:
|
// On détermine dès le départ où se trouve le fichier:
|
||||||
Chercher_repertoire_du_programme(argv[0]);
|
Chercher_repertoire_du_programme(argv[0]);
|
||||||
|
|
||||||
// On détecte les lecteurs qui sont accessibles:
|
// On détecte les lecteurs qui sont accessibles:
|
||||||
Rechercher_drives();
|
Rechercher_drives();
|
||||||
// On détermine le répertoire courant:
|
// On détermine le répertoire courant:
|
||||||
@ -630,9 +615,6 @@ void Fermeture_du_programme(void)
|
|||||||
// On prend bien soin de passer dans le répertoire initial:
|
// On prend bien soin de passer dans le répertoire initial:
|
||||||
if (chdir(Repertoire_initial)!=-1)
|
if (chdir(Repertoire_initial)!=-1)
|
||||||
{
|
{
|
||||||
/* A revoir ...
|
|
||||||
_dos_setdrive(Repertoire_initial[0]-64,&Bidon);
|
|
||||||
*/
|
|
||||||
// On sauvegarde les données dans le .CFG et dans le .INI
|
// On sauvegarde les données dans le .CFG et dans le .INI
|
||||||
if (Config.Auto_save)
|
if (Config.Auto_save)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user