3 * - Directory Management Functions
11 extern tVFS_Mount *gRootMount;
14 int VFS_MkDir(char *Path);
15 int VFS_MkNod(char *Path, Uint Flags);
19 * \fn int VFS_MkDir(char *Path)
20 * \brief Create a new node
21 * \param Path Path of directory to create
23 int VFS_MkDir(char *Path)
25 return VFS_MkNod(Path, VFS_FFLAG_DIRECTORY);
29 * \fn int VFS_MkNod(char *Path, Uint Flags)
30 * \brief Create a new node in a directory
31 * \param Path Path of new node
32 * \param Flags Flags to apply to the node
34 int VFS_MkNod(char *Path, Uint Flags)
37 int pos = 0, oldpos = 0;
42 ENTER("sPath xFlags", Path, Flags);
44 absPath = VFS_GetAbsPath(Path);
45 LOG("absPath = '%s'", absPath);
47 while( (next = strpos(&absPath[pos+1], '/')) != -1 ) {
48 LOG("next = %i", next);
53 absPath[oldpos] = '\0'; // Mutilate path
54 name = &absPath[oldpos+1];
56 LOG("absPath = '%s', name = '%s'", absPath, name);
59 if(absPath[0] == '\0')
60 parent = VFS_ParsePath("/", NULL);
62 parent = VFS_ParsePath(absPath, NULL);
64 LOG("parent = %p", parent);
68 return -1; // Error Check
72 if( !VFS_CheckACL(parent, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
73 if(parent->Close) parent->Close( parent );
79 LOG("parent = %p", parent);
81 if(parent->MkNod == NULL) {
82 Warning("VFS_MkNod - Directory has no MkNod method");
88 ret = parent->MkNod(parent, name, Flags);
90 // Free allocated string
94 if(parent->Close) parent->Close( parent );
107 * \fn int VFS_Symlink(char *Name, char *Link)
108 * \brief Creates a symlink called \a Name to \a Link
109 * \param Name Name of symbolic link
110 * \param Link Destination of symbolic link
112 int VFS_Symlink(char *Name, char *Link)
118 //ENTER("sName sLink", Name, Link);
120 // Get absolue path name
121 Link = VFS_GetAbsPath( Link );
123 Warning("Path '%s' is badly formed", Link);
127 // Get true path and node
128 destNode = VFS_ParsePath( Link, &realLink );
131 // Check if destination exists
133 Warning("File '%s' does not exist, symlink not created", Link);
137 // Derefence the destination
138 if(destNode->Close) destNode->Close(destNode);
141 if( VFS_MkNod(Name, VFS_FFLAG_SYMLINK) != 0 ) {
142 Warning("Unable to create link node '%s'", Name);
143 return -2; // Make link node
146 // Write link address
147 fp = VFS_Open(Name, VFS_OPENFLAG_WRITE|VFS_OPENFLAG_NOLINK);
148 VFS_Write(fp, strlen(realLink), realLink);
157 * \fn int VFS_ReadDir(int FD, char *Dest)
158 * \brief Read from a directory
160 int VFS_ReadDir(int FD, char *Dest)
162 tVFS_Handle *h = VFS_GetHandle(FD);
165 //ENTER("ph pDest", h, Dest);
167 if(!h || h->Node->ReadDir == NULL) {
172 if(h->Node->Size != -1 && h->Position >= h->Node->Size) {
178 tmp = h->Node->ReadDir(h->Node, h->Position);
179 if((Uint)tmp < (Uint)VFS_MAXSKIP)
180 h->Position += (Uint)tmp;
183 } while(tmp != NULL && (Uint)tmp < (Uint)VFS_MAXSKIP);
185 //LOG("tmp = '%s'", tmp);