-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the name of file_id to identifier.
- Loading branch information
Showing
15 changed files
with
211 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2024 AQ author, All Rights Reserved. | ||
// This program is licensed under the AQ License. You can find the AQ license in | ||
// the root directory. | ||
|
||
#include "aqvm/base/file/identifier/identifier.h" | ||
|
||
#include <stdint.h> | ||
|
||
#include "aqvm/base/file/file.h" | ||
|
||
#ifdef __unix__ | ||
#include "aqvm/base/file/identifier/unix/identifier.h" | ||
#elif _WIN32 | ||
#include "aqvm/base/file/identifier/windows/identifier.h" | ||
#endif | ||
|
||
int AqvmBaseFileIdentifier_GetIdentifier(const char* filename, | ||
AqvmBaseFileIdentifier_Identifier* identifier) { | ||
if (filename == NULL || identifier == NULL) { | ||
// TODO | ||
return -1; | ||
} | ||
|
||
#ifdef __unix__ | ||
if (AqvmBaseFileIdentifierUnix_GetIdentifier(filename, identifier) != 0) { | ||
// TODO | ||
return -2; | ||
} | ||
#elif _WIN32 | ||
if (AqvmBaseFileIdentifierWindows_GetIdentifier(filename, identifier) != 0) { | ||
// TODO | ||
return -3; | ||
} | ||
#else | ||
// TODO | ||
return -4; | ||
#endif | ||
|
||
return 0; | ||
} | ||
|
||
uint32_t AqvmBaseFileIdentifier_GetIdentifierHash( | ||
const AqvmBaseFileIdentifier_Identifier* identifier) { | ||
if (identifier == NULL) { | ||
// TODO | ||
return 0; | ||
} | ||
|
||
#ifdef __unix__ | ||
return AqvmBaseFileIdentifierUnix_GetIdentifierHash(identifier); | ||
#elif _WIN32 | ||
return AqvmBaseFileIdentifierWindows_GetIdentifierHash(identifier); | ||
#else | ||
// TODO | ||
return 0; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 AQ author, All Rights Reserved. | ||
// This program is licensed under the AQ License. You can find the AQ license in | ||
// the root directory. | ||
|
||
#ifndef AQVM_BASE_FILE_IDENTIFIER_IDENTIFIER_H_ | ||
#define AQVM_BASE_FILE_IDENTIFIER_IDENTIFIER_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __unix__ | ||
#include "aqvm/base/file/identifier/unix/identifier.h" | ||
#elif _WIN32 | ||
#include "aqvm/base/file/identifier/windows/identifier.h" | ||
#endif | ||
|
||
#ifdef __unix__ | ||
typedef AqvmBaseFileIdentifierUnix_Identifier AqvmBaseFileIdentifier_Identifier; | ||
#elif _WIN32 | ||
typedef AqvmBaseFileIdentifierWindows_Identifier AqvmBaseFileIdentifier_Identifier; | ||
#else | ||
typedef void AqvmBaseFileIdentifier_Identifier; | ||
#endif | ||
|
||
int AqvmBaseFileIdentifier_GetIdentifier(const char* filename, | ||
AqvmBaseFileIdentifier_Identifier* identifier); | ||
|
||
uint32_t AqvmBaseFileIdentifier_GetIdentifierHash(const AqvmBaseFileIdentifier_Identifier* identifier); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifdef __unix__ | ||
// Copyright 2024 AQ author, All Rights Reserved. | ||
// This program is licensed under the AQ License. You can find the AQ license in | ||
// the root directory. | ||
|
||
#include "aqvm/base/file/identifier/unix/identifier.h" | ||
|
||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
|
||
#include "aqvm/base/hash/hash.h" | ||
|
||
int AqvmBaseFileIdentifierUnix_GetIdentifier(const char* filename, | ||
AqvmBaseFileIdentifierUnix_Identifier* identifier) { | ||
if (filename == NULL || identifier == NULL) { | ||
// TODO | ||
return -1; | ||
} | ||
|
||
struct stat* file_info; | ||
|
||
if (stat(filename, file_info) != 0) { | ||
// TODO | ||
return -2; | ||
} | ||
|
||
identifier->st_dev = file_info->st_dev; | ||
identifier->st_ino = file_info->st_ino; | ||
|
||
return 0; | ||
} | ||
|
||
uint32_t AqvmBaseFileIdentifierUnix_GetIdentifierHash( | ||
const AqvmBaseFileIdentifierUnix_Identifier* identifier) { | ||
if (identifier == NULL) { | ||
// TODO | ||
return 0; | ||
} | ||
uint32_t hash[2]; | ||
|
||
hash[0] = identifier->st_dev; | ||
hash[1] = identifier->st_ino; | ||
|
||
return AqvmBaseHash_HashUnsignedIntArray(hash, 2); | ||
} | ||
|
||
#endif |
Oops, something went wrong.