1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** FileX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** Directory */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
/**************************************************************************/ |
22 |
|
|
|
23 |
|
|
#define FX_SOURCE_CODE |
24 |
|
|
|
25 |
|
|
|
26 |
|
|
/* Include necessary system files. */ |
27 |
|
|
|
28 |
|
|
#include "fx_api.h" |
29 |
|
|
#include "fx_directory.h" |
30 |
|
|
#include "fx_utility.h" |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _fx_directory_default_get_copy PORTABLE C */ |
37 |
|
|
/* 6.1.6 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* William E. Lamie, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function copies the last path provided to the */ |
45 |
|
|
/* fx_directory_default_set function into the specified buffer. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* media_ptr Media control block pointer */ |
50 |
|
|
/* return_path_name_buffer Destination buffer for name */ |
51 |
|
|
/* return_path_name_buffer_size Size of buffer pointed to by */ |
52 |
|
|
/* return_path_name_buffer */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* return status */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* None */ |
61 |
|
|
/* */ |
62 |
|
|
/* CALLED BY */ |
63 |
|
|
/* */ |
64 |
|
|
/* Application Code */ |
65 |
|
|
/* */ |
66 |
|
|
/**************************************************************************/ |
67 |
|
3 |
UINT _fx_directory_default_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size) |
68 |
|
|
{ |
69 |
|
|
|
70 |
|
|
UINT status; |
71 |
|
|
CHAR *return_path_name; |
72 |
|
|
UINT path_name_length_with_null_terminator; |
73 |
|
|
|
74 |
|
|
|
75 |
|
|
/* Get the pointer to the path. */ |
76 |
|
3 |
status = _fx_directory_default_get(media_ptr, &return_path_name); |
77 |
✓✓ |
3 |
if (status == FX_SUCCESS) |
78 |
|
|
{ |
79 |
|
|
|
80 |
|
|
/* Get the length of the path. */ |
81 |
|
2 |
path_name_length_with_null_terminator = _fx_utility_string_length_get(return_path_name, FX_MAXIMUM_PATH) + 1; |
82 |
|
|
|
83 |
|
|
/* Can it fit in the user's buffer? */ |
84 |
✓✓ |
2 |
if (path_name_length_with_null_terminator <= return_path_name_buffer_size) |
85 |
|
|
{ |
86 |
|
|
|
87 |
|
|
/* Copy the path name into the user's buffer. */ |
88 |
|
1 |
_fx_utility_memory_copy((UCHAR *) return_path_name, (UCHAR *) return_path_name_buffer, path_name_length_with_null_terminator); /* Use case of memcpy is verified. */ |
89 |
|
|
} |
90 |
|
|
else |
91 |
|
|
{ |
92 |
|
|
|
93 |
|
|
/* Buffer is too small. Return error. */ |
94 |
|
1 |
return(FX_BUFFER_ERROR); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
/* Return successful status. */ |
100 |
|
2 |
return(status); |
101 |
|
|
} |
102 |
|
|
|