+ maxhandles = *Threads_GetMaxFD();
+ memcpy(ent->Handles, cur->Handles, maxhandles*sizeof(tVFS_Handle));
+
+ // Reference all
+ for( int i = 0; i < maxhandles; i ++ )
+ {
+ if(!ent->Handles[i].Node) continue;
+
+ if(ent->Handles[i].Node->Type->Reference)
+ ent->Handles[i].Node->Type->Reference(ent->Handles[i].Node);
+ }
+}
+
+void VFS_CloneHandlesFromList(int PID, int nFD, int FDs[])
+{
+ tUserHandles *ent;
+ const tUserHandles *cur;
+ int maxhandles;
+
+ cur = VFS_int_GetUserHandles(Threads_GetPID(), 0);
+ if(!cur) return ; // Don't need to do anything if the current list is empty
+
+ ent = VFS_int_GetUserHandles(PID, 1);
+
+ LOG("Copying %i FDs from %i", nFD, PID);
+
+ maxhandles = *Threads_GetMaxFD();
+ if( nFD > maxhandles )
+ nFD = maxhandles;
+ for( int i = 0; i < nFD; i ++ )
+ {
+ int fd = FDs[i];
+ if( fd >= maxhandles ) {
+ ent->Handles[i].Node = NULL;
+ continue ;
+ }
+ memcpy(&ent->Handles[i], &cur->Handles[fd], sizeof(tVFS_Handle));
+ }
+ for( int i = nFD; i < maxhandles; i ++ )
+ ent->Handles[i].Node = NULL;