Changeset 101930 in vbox for trunk/src/libs/xpcom18a4/nsprpub/pr
- Timestamp:
- Nov 7, 2023 11:16:52 AM (15 months ago)
- Location:
- trunk/src/libs/xpcom18a4/nsprpub/pr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_unixos.h
r101874 r101930 351 351 extern PRInt32 _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info); 352 352 extern PRInt32 _MD_rename(const char *from, const char *to); 353 extern PRInt32 _MD_access(const char *name, PRAccessHow how);354 353 extern PRInt32 _MD_mkdir(const char *name, PRIntn mode); 355 354 extern PRInt32 _MD_rmdir(const char *name); … … 372 371 #define _MD_GETOPENFILEINFO64(fd, info) _MD_getopenfileinfo64(fd, info) 373 372 #define _MD_RENAME(from, to) _MD_rename(from, to) 374 #define _MD_ACCESS(name, how) _MD_access(name, how)375 373 #define _MD_MKDIR(name, mode) _MD_mkdir(name, mode) 376 374 #define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode) -
trunk/src/libs/xpcom18a4/nsprpub/pr/include/prio.h
r101891 r101930 54 54 #define PR_GetInheritedFD VBoxNsprPR_GetInheritedFD 55 55 #define PR_SetFDInheritable VBoxNsprPR_SetFDInheritable 56 #define PR_Access VBoxNsprPR_Access57 56 #define PR_Open VBoxNsprPR_Open 58 57 #define PR_Read VBoxNsprPR_Read … … 91 90 #define PR_Writev VBoxNsprPR_Writev 92 91 #define PR_Delete VBoxNsprPR_Delete 93 #define PR_Rename VBoxNsprPR_Rename94 92 #define PR_GetFileInfo VBoxNsprPR_GetFileInfo 95 93 #define PR_GetFileInfo64 VBoxNsprPR_GetFileInfo64 … … 98 96 #define PR_Available VBoxNsprPR_Available 99 97 #define PR_Sync VBoxNsprPR_Sync 100 #define PR_MkDir VBoxNsprPR_MkDir101 #define PR_MakeDir VBoxNsprPR_MakeDir102 #define PR_RmDir VBoxNsprPR_RmDir103 98 #define PR_OpenTCPSocket VBoxNsprPR_OpenTCPSocket 104 99 #define PR_ConnectContinue VBoxNsprPR_ConnectContinue … … 891 886 892 887 /* 893 **************************************************************************894 * FUNCTION: PR_Rename895 * DESCRIPTION:896 * Rename a file from the old name 'from' to the new name 'to'.897 * INPUTS:898 * const char *from899 * The old name of the file to be renamed.900 * const char *to901 * The new name of the file.902 * OUTPUTS:903 * None.904 * RETURN: PRStatus905 **************************************************************************906 */907 908 NSPR_API(PRStatus) PR_Rename(const char *from, const char *to);909 910 /*911 *************************************************************************912 * FUNCTION: PR_Access913 * DESCRIPTION:914 * Determine accessibility of a file.915 * INPUTS:916 * const char *name917 * path name of the file918 * PRAccessHow how919 * specifies which access permission to check for.920 * It can be one of the following values:921 * PR_ACCESS_READ_OK Test for read permission922 * PR_ACCESS_WRITE_OK Test for write permission923 * PR_ACCESS_EXISTS Check existence of file924 * OUTPUTS:925 * None.926 * RETURN: PRStatus927 * PR_SUCCESS is returned if the requested access is permitted.928 * Otherwise, PR_FAILURE is returned. Additional information929 * regarding the reason for the failure may be retrieved from930 * PR_GetError().931 *************************************************************************932 */933 934 typedef enum PRAccessHow {935 PR_ACCESS_EXISTS = 1,936 PR_ACCESS_WRITE_OK = 2,937 PR_ACCESS_READ_OK = 3938 } PRAccessHow;939 940 NSPR_API(PRStatus) PR_Access(const char *name, PRAccessHow how);941 942 /*943 888 ************************************************************************* 944 889 * FUNCTION: PR_Seek, PR_Seek64 … … 1103 1048 /* 1104 1049 ************************************************************************* 1105 * FUNCTION: PR_MkDir1106 * DESCRIPTION:1107 * Create a new directory with the given name and access mode.1108 * INPUTS:1109 * const char *name1110 * The name of the directory to be created. All the path components1111 * up to but not including the leaf component must already exist.1112 * PRIntn mode1113 * See 'mode' definiton in PR_Open().1114 * OUTPUTS:1115 * None1116 * RETURN: PRStatus1117 * If successful, will return a status of PR_SUCCESS. Otherwise1118 * a value of PR_FAILURE. The reason for the failure may be re-1119 * trieved using PR_GetError().1120 *************************************************************************1121 */1122 1123 NSPR_API(PRStatus) PR_MkDir(const char *name, PRIntn mode);1124 1125 /*1126 *************************************************************************1127 * FUNCTION: PR_MakeDir1128 * DESCRIPTION:1129 * Create a new directory with the given name and access mode.1130 * PR_MakeDir has the same prototype as PR_MkDir but implements1131 * the specified access mode where possible.1132 *************************************************************************1133 */1134 1135 NSPR_API(PRStatus) PR_MakeDir(const char *name, PRIntn mode);1136 1137 /*1138 *************************************************************************1139 * FUNCTION: PR_RmDir1140 * DESCRIPTION:1141 * Remove a directory by the given name.1142 * INPUTS:1143 * const char *name1144 * The name of the directory to be removed. All the path components1145 * must already exist. Only the leaf component will be removed.1146 * OUTPUTS:1147 * None1148 * RETURN: PRStatus1149 * If successful, will return a status of PR_SUCCESS. Otherwise1150 * a value of PR_FAILURE. The reason for the failure may be re-1151 * trieved using PR_GetError().1152 **************************************************************************1153 */1154 1155 NSPR_API(PRStatus) PR_RmDir(const char *name);1156 1157 /*1158 *************************************************************************1159 1050 * FUNCTION: PR_OpenTCPSocket 1160 1051 * DESCRIPTION: -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptio.c
r101891 r101930 116 116 PRIntn osfd, PRDescType type, PRBool isAcceptedSocket, PRBool imported); 117 117 118 static PRLock *_pr_flock_lock; /* For PR_LockFile() etc. */119 static PRCondVar *_pr_flock_cv; /* For PR_LockFile() etc. */120 118 static PRLock *_pr_rename_lock; /* For PR_Rename() */ 121 119 … … 621 619 #endif 622 620 623 _pr_flock_lock = PR_NewLock();624 PR_ASSERT(NULL != _pr_flock_lock);625 _pr_flock_cv = PR_NewCondVar(_pr_flock_lock);626 PR_ASSERT(NULL != _pr_flock_cv);627 621 _pr_rename_lock = PR_NewLock(); 628 622 PR_ASSERT(NULL != _pr_rename_lock); … … 668 662 _PR_CleanupFdCache(); 669 663 670 if (_pr_flock_cv)671 {672 PR_DestroyCondVar(_pr_flock_cv);673 _pr_flock_cv = NULL;674 }675 if (_pr_flock_lock)676 {677 PR_DestroyLock(_pr_flock_lock);678 _pr_flock_lock = NULL;679 }680 664 if (_pr_rename_lock) 681 665 { … … 2101 2085 } /* PR_Delete */ 2102 2086 2103 PR_IMPLEMENT(PRStatus) PR_Access(const char *name, PRAccessHow how)2104 {2105 PRIntn rv;2106 2107 if (pt_TestAbort()) return PR_FAILURE;2108 2109 switch (how)2110 {2111 case PR_ACCESS_READ_OK:2112 rv = access(name, R_OK);2113 break;2114 case PR_ACCESS_WRITE_OK:2115 rv = access(name, W_OK);2116 break;2117 case PR_ACCESS_EXISTS:2118 default:2119 rv = access(name, F_OK);2120 }2121 if (0 == rv) return PR_SUCCESS;2122 pt_MapError(_PR_MD_MAP_ACCESS_ERROR, errno);2123 return PR_FAILURE;2124 2125 } /* PR_Access */2126 2127 2087 PR_IMPLEMENT(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info) 2128 2088 { … … 2139 2099 return (0 == rv) ? PR_SUCCESS : PR_FAILURE; 2140 2100 } /* PR_GetFileInfo64 */ 2141 2142 PR_IMPLEMENT(PRStatus) PR_Rename(const char *from, const char *to)2143 {2144 PRIntn rv = -1;2145 2146 if (pt_TestAbort()) return PR_FAILURE;2147 2148 /*2149 ** We have to acquire a lock here to stiffle anybody trying to create2150 ** a new file at the same time. And we have to hold that lock while we2151 ** test to see if the file exists and do the rename. The other place2152 ** where the lock is held is in PR_Open() when possibly creating a2153 ** new file.2154 */2155 2156 PR_Lock(_pr_rename_lock);2157 rv = access(to, F_OK);2158 if (0 == rv)2159 {2160 PR_SetError(PR_FILE_EXISTS_ERROR, 0);2161 rv = -1;2162 }2163 else2164 {2165 rv = rename(from, to);2166 if (rv == -1)2167 pt_MapError(_PR_MD_MAP_RENAME_ERROR, errno);2168 }2169 PR_Unlock(_pr_rename_lock);2170 return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;2171 } /* PR_Rename */2172 2101 2173 2102 PR_IMPLEMENT(PRStatus) PR_CloseDir(PRDir *dir) … … 2187 2116 return PR_SUCCESS; 2188 2117 } /* PR_CloseDir */ 2189 2190 PR_IMPLEMENT(PRStatus) PR_MakeDir(const char *name, PRIntn mode)2191 {2192 PRInt32 rv = -1;2193 2194 if (pt_TestAbort()) return PR_FAILURE;2195 2196 /*2197 ** This lock is used to enforce rename semantics as described2198 ** in PR_Rename.2199 */2200 if (NULL !=_pr_rename_lock)2201 PR_Lock(_pr_rename_lock);2202 rv = mkdir(name, mode);2203 if (-1 == rv)2204 pt_MapError(_PR_MD_MAP_MKDIR_ERROR, errno);2205 if (NULL !=_pr_rename_lock)2206 PR_Unlock(_pr_rename_lock);2207 2208 return (-1 == rv) ? PR_FAILURE : PR_SUCCESS;2209 } /* PR_Makedir */2210 2211 PR_IMPLEMENT(PRStatus) PR_MkDir(const char *name, PRIntn mode)2212 {2213 return PR_MakeDir(name, mode);2214 } /* PR_Mkdir */2215 2216 PR_IMPLEMENT(PRStatus) PR_RmDir(const char *name)2217 {2218 PRInt32 rv;2219 2220 if (pt_TestAbort()) return PR_FAILURE;2221 2222 rv = rmdir(name);2223 if (0 == rv) {2224 return PR_SUCCESS;2225 } else {2226 pt_MapError(_PR_MD_MAP_RMDIR_ERROR, errno);2227 return PR_FAILURE;2228 }2229 } /* PR_Rmdir */2230 2231 2118 2232 2119 PR_IMPLEMENT(PRDir*) PR_OpenDir(const char *name)
Note:
See TracChangeset
for help on using the changeset viewer.