1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** FileX Component                                                       */
16 /**                                                                       */
17 /**   Directory                                                           */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define FX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "fx_api.h"
28 #include "fx_system.h"
29 #include "fx_file.h"
30 #include "fx_utility.h"
31 #include "fx_directory.h"
32 
33 #ifndef FX_NO_LOCAL_PATH
34 FX_LOCAL_PATH_SETUP
35 #endif
36 
37 
38 /**************************************************************************/
39 /*                                                                        */
40 /*  FUNCTION                                               RELEASE        */
41 /*                                                                        */
42 /*    _fx_directory_local_path_clear                      PORTABLE C      */
43 /*                                                           6.1          */
44 /*  AUTHOR                                                                */
45 /*                                                                        */
46 /*    William E. Lamie, Microsoft Corporation                             */
47 /*                                                                        */
48 /*  DESCRIPTION                                                           */
49 /*                                                                        */
50 /*    This function clears the local default directory of the media so    */
51 /*    any path relative operations will start using the media's global    */
52 /*    default path again.                                                 */
53 /*                                                                        */
54 /*  INPUT                                                                 */
55 /*                                                                        */
56 /*    media_ptr                             Media control block pointer   */
57 /*                                                                        */
58 /*  OUTPUT                                                                */
59 /*                                                                        */
60 /*    return status                                                       */
61 /*                                                                        */
62 /*  CALLS                                                                 */
63 /*                                                                        */
64 /*    None                                                                */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
75 /*  09-30-2020     William E. Lamie         Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_fx_directory_local_path_clear(FX_MEDIA * media_ptr)79 UINT  _fx_directory_local_path_clear(FX_MEDIA *media_ptr)
80 {
81 
82 
83 #ifndef FX_MEDIA_STATISTICS_DISABLE
84 
85     /* Increment the number of times this service has been called.  */
86     media_ptr -> fx_media_directory_local_path_clears++;
87 #endif
88 
89     /* Check the media to make sure it is open.  */
90     if (media_ptr -> fx_media_id != FX_MEDIA_ID)
91     {
92 
93         /* Return the media not opened error.  */
94         return(FX_MEDIA_NOT_OPEN);
95     }
96 
97 #ifdef FX_NO_LOCAL_PATH
98 
99     /* Error, return to caller.  */
100     return(FX_NOT_IMPLEMENTED);
101 #else
102 
103     /* If trace is enabled, insert this event into the trace buffer.  */
104     FX_TRACE_IN_LINE_INSERT(FX_TRACE_DIRECTORY_LOCAL_PATH_CLEAR, media_ptr, 0, 0, 0, FX_TRACE_DIRECTORY_EVENTS, 0, 0)
105 
106     /* Clear this thread's local path pointer.  */
107     _tx_thread_current_ptr -> tx_thread_filex_ptr =  FX_NULL;
108 
109     /* Local default directory clear is complete, return status.  */
110     return(FX_SUCCESS);
111 #endif
112 }
113 
114