예제 #1
0
파일: system.c 프로젝트: Xeeynamo/smallHex
bool DirectoryRename(const char *strDirectoryName, const char *strNewDirectoryName)
{
#if defined(_WIN32)
	return MoveFile(strDirectoryName, strNewDirectoryName) != 0;
#elif defined(PLATFORM_PSP2)
	return sceIoRename(strDirectoryName, strNewDirectoryName) >= 0;
#endif
	return false;
}
예제 #2
0
파일: fs_hooks.c 프로젝트: 173210/VHL
int hook_sceIoRename (const char *oldname, const char *newname)
{
        state_machine_checkState();

        char o_tmpPath[MAX_PATH_LENGTH];
        char n_tmpPath[MAX_PATH_LENGTH];
        char *o_tmp = TranslateVFS(o_tmpPath, oldname);
        char *n_tmp = TranslateVFS(n_tmpPath, newname);

        return sceIoRename(o_tmp, n_tmp);
}
예제 #3
0
int hook_sceIoRename (const char *oldname, const char *newname)
{
        sceKernelCheckCallback();

        char o_tmpPath[MAX_PATH_LENGTH];
        char n_tmpPath[MAX_PATH_LENGTH];
        char *o_tmp = TranslateVFS(o_tmpPath, oldname);
        char *n_tmp = TranslateVFS(n_tmpPath, newname);

        return sceIoRename(o_tmp, n_tmp);
}
예제 #4
0
파일: ftp.c 프로젝트: jadfeitrouni/FTPVita
static void cmd_RNTO_func(ClientInfo *client)
{
	char path_to[PATH_MAX];
	/* Get the destination filename */
	gen_filepath(client, path_to);

	DEBUG("Renaming: %s to %s\n", client->rename_path, path_to);

	if (sceIoRename(client->rename_path, path_to) < 0) {
		client_send_ctrl_msg(client, "550 Error renaming the file.\n");
	}

	client_send_ctrl_msg(client, "226 Rename completed.\n");
}
예제 #5
0
파일: file.c 프로젝트: sfsy1989/j2me
/**
 * Renames the filename.
 * @param unicodeOldFilename current name of file
 * @param oldNameLen current name length
 * @param unicodeNewFilename new name of file
 * @param newNameLen length of new name
 * @return <tt>JAVACALL_OK</tt>  on success, 
 *         <tt>JAVACALL_FAIL</tt> or negative value otherwise
 */
javacall_result javacall_file_rename(const javacall_utf16 * unicodeOldFilename, int oldNameLen, 
        const javacall_utf16 * unicodeNewFilename, int newNameLen) {
    //TODO: It looks not work properly, need to investigate. Currently it won't be called
    
    static char oldfn[MAX_FILE_NAME_LEN+1];
    char* pszOldFilename = javacall_UNICODEsToUtf8(unicodeOldFilename, oldNameLen);
    if (pszOldFilename == NULL) {
        return JAVACALL_FAIL;
    }
    
    strcpy(oldfn, pszOldFilename);

    char* pszNewFilename = javacall_UNICODEsToUtf8(unicodeNewFilename, newNameLen);
    if (pszNewFilename == NULL) {        
        return JAVACALL_FAIL;
    }

    int status = sceIoRename(oldfn, pszNewFilename);
    return (status == 0) ? JAVACALL_OK : JAVACALL_FAIL;

}
예제 #6
0
파일: config.c 프로젝트: FTPiano/psplinkusb
void configChange(const char *bootpath, const char *newname, const char *newval, int mode)
{
	char cnf_path[256];
	char new_path[256];
	int found = 0;
	struct ConfigFile cnf;
	int fd = -1;

	if((mode != CONFIG_MODE_ADD) && (mode != CONFIG_MODE_DEL))
	{
		return;
	}

	strcpy(cnf_path, bootpath);
	strcat(cnf_path, "psplink.ini");
	SHELL_PRINT("Config Path %s\n", cnf_path);

	strcpy(new_path, bootpath);
	strcat(new_path, "psplink.ini.tmp");
	fd = sceIoOpen(new_path, PSP_O_WRONLY | PSP_O_TRUNC | PSP_O_CREAT, 0777);
	if(fd >= 0)
	{
		if(psplinkConfigOpen(cnf_path, &cnf))
		{
			const char *name;
			const char *val;

			while((val = psplinkConfigReadNext(&cnf, &name)))
			{
				if(strcmp(name, newname) == 0)
				{
					if(mode == CONFIG_MODE_ADD)
					{
						fdprintf(fd, "%s=\"%s\"\n", newname, newval);
						found = 1;
					}
				}
				else
				{
					fdprintf(fd, "%s=\"%s\"\n", name, val);
				}
			}

			if((mode == CONFIG_MODE_ADD) && (!found))
			{
				fdprintf(fd, "%s=\"%s\"\n", newname, newval);
			}

			sceIoClose(fd);
			fd = -1;
			psplinkConfigClose(&cnf);

			if(sceIoRemove(cnf_path) < 0)
			{
				SHELL_PRINT("Error deleting original configuration\n");
			}
			else
			{
				if(sceIoRename(new_path, cnf_path) < 0)
				{
					SHELL_PRINT("Error renaming configuration\n");
				}
			}
		}
		else
		{
			SHELL_PRINT("Couldn't open temporary config file %s\n", new_path);
		}

		if(fd >= 0)
		{
			sceIoClose(fd);
			sceIoRemove(new_path);
		}
	}
}
예제 #7
0
int rename (const char *oldpath,const char *newpath){
  char fulloldpath[PATH_MAX];
  char fullnewpath[PATH_MAX];
  return seterrno(sceIoRename(convert_path(fulloldpath,oldpath),convert_path(fullnewpath,newpath)) );
}
예제 #8
0
int main(int argc, char *argv[]) {
	checkpoint("  Create test file 1: %08x", makeTestFile("ms0:/__iorename_test1.txt"));
	checkpoint("  Create test file 2: %08x", makeTestFile("ms0:/__iorename_test2.txt"));
	checkpoint("  Create test file 3: %08x", makeTestFile("ms0:/__iorename_test3.txt"));

	checkpointNext("Rename behavior:");

	checkpoint("  sceIoChdir host0:/: %08x", sceIoChdir("host0:/"));
	checkpoint("  sceIoRename abs -> abs: %08x", sceIoRename("ms0:/__iorename_test1.txt", "ms0:/__iorename_test1a.txt"));
	checkpoint("  sceIoRename abs -> abs overwrite: %08x", sceIoRename("ms0:/__iorename_test1a.txt", "ms0:/__iorename_test2.txt"));

	checkpoint("  sceIoChdir ms0:/PSP: %08x", sceIoChdir("ms0:/PSP"));
	checkpoint("  sceIoRename rel -> rel: %08x", sceIoRename("../__iorename_test2.txt", "__iorename_test2a.txt"));
	checkpoint("    renamed to: %s", fileExists("ms0:/__iorename_test2a.txt") ? "origin dir" : (fileExists("ms0:/PSP/__iorename_test2a.txt") ? "cwd" : "nowhere?"));

	checkpoint("  sceIoRename rel -> abs: %08x", sceIoRename("../__iorename_test3.txt", "ms0:/PSP/__iorename_test3a.txt"));
	checkpoint("    renamed to: %s", fileExists("ms0:/__iorename_test3a.txt") ? "origin dir" : (fileExists("ms0:/PSP/__iorename_test3a.txt") ? "dest dir" : "nowhere?"));

	// Okay, we've moved everything around a lot, let's clean it up.
	sceIoRemove("ms0:/__iorename_test1.txt");
	sceIoRemove("ms0:/__iorename_test1a.txt");
	sceIoRemove("ms0:/__iorename_test2.txt");
	sceIoRemove("ms0:/__iorename_test2a.txt");
	sceIoRemove("ms0:/__iorename_test3.txt");
	sceIoRemove("ms0:/__iorename_test3a.txt");
	sceIoRemove("ms0:/PSP/__iorename_test2a.txt");
	sceIoRemove("ms0:/PSP/__iorename_test3a.txt");

	checkpointNext("Error handling:");
	checkpoint("  Recreate test file 1: %08x", makeTestFile("ms0:/__iorename_test1.txt"));
	checkpoint("  Recreate test file 2: %08x", makeTestFile("ms0:/__iorename_test2.txt"));

	checkpoint("  sceIoRename cross device: %08x", sceIoRename("ms0:/__iorename_test1.txt", "host0:/__iorename_test1.txt"));
	checkpoint("  sceIoRename bad dest path: %08x", sceIoRename("ms0:/__iorename_test2.txt", "ms0:/__DOES_NOT_EXIST/__iorename_test2.txt"));
	checkpoint("  sceIoRename bad src path: %08x", sceIoRename("ms0:/_DOES_NOT_EXIST/__iorename_test3.txt", "ms0:/__iorename_test3.txt"));
	checkpoint("  sceIoRename bad src file: %08x", sceIoRename("ms0:/__iorename_test3.txt", "ms0:/__iorename_test3a.txt"));
	checkpoint("  sceIoRename same path: %08x", sceIoRename("ms0:/__iorename_test1.txt", "ms0:/__iorename_test1.txt"));
	// Crash.
	//checkpoint("  sceIoRename NULL -> rel", sceIoRename(NULL, "test.txt"));
	//checkpoint("  sceIoRename rel -> NULL", sceIoRename("test.txt", NULL));
	//checkpoint("  sceIoRename NULL -> NULL", sceIoRename(NULL, NULL));
	checkpoint("  sceIoRename wild -> rel: %08x", sceIoRename("ms0:/__iorename_test*.txt", "ms0:/__iorename_test1a.txt"));
	checkpoint("  sceIoRename rel -> wild: %08x", sceIoRename("ms0:/__iorename_test1.txt", "ms0:/__iorename_test*.txt"));
	checkpoint("  sceIoRename wild -> wild: %08x", sceIoRename("ms0:/__iorename_test?.txt", "ms0:/__iorename_test?.txt"));

	sceIoRemove("ms0:/__iorename_test1.txt");
	sceIoRemove("ms0:/__iorename_test2.txt");
	sceIoRemove("host0:/__iorename_test1.txt");

	return 0;
}
예제 #9
0
		bool	Move( const char * p_existing, const char * p_new )
		{
			return sceIoRename( p_existing, p_new ) >= 0;
		}
예제 #10
0
int copy_thread(SceSize args_size, CopyArguments *args) {
	SceUID thid = -1;

	// Set progress to 0%
	sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0);
	sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage

	char src_path[MAX_PATH_LENGTH], dst_path[MAX_PATH_LENGTH];
	FileListEntry *copy_entry = NULL;

	if (args->copy_mode == COPY_MODE_MOVE) { // Move
		// Update thread
		thid = createStartUpdateThread(args->copy_list->length);

		copy_entry = args->copy_list->head;

		int i;
		for (i = 0; i < args->copy_list->length; i++) {
			snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name);
			snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name);

			int res = sceIoRename(src_path, dst_path);
			// TODO: if (res == SCE_ERROR_ERRNO_EEXIST) if folder
			if (res < 0) {
				closeWaitDialog();
				errorDialog(res);
				goto EXIT;
			}

			SetProgress(i + 1, args->copy_list->length);

			copy_entry = copy_entry->next;
		}

		// Set progress to 100%
		sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100);
		sceKernelDelayThread(COUNTUP_WAIT);

		// Close
		sceMsgDialogClose();

		dialog_step = DIALOG_STEP_MOVED;
	} else { // Copy
		if (args->copy_mode == COPY_MODE_EXTRACT)
			archiveOpen(args->archive_path);

		// Get src paths info
		uint32_t size = 0, folders = 0, files = 0;

		copy_entry = args->copy_list->head;

		int i;
		for (i = 0; i < args->copy_list->length; i++) {
			disableAutoSuspend();

			snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name);

			if (args->copy_mode == COPY_MODE_EXTRACT) {
				addEndSlash(src_path);
				getArchivePathInfo(src_path, &size, &folders, &files);
			} else {
				removeEndSlash(src_path);
				getPathInfo(src_path, &size, &folders, &files);
			}

			copy_entry = copy_entry->next;
		}

		// Update thread
		thid = createStartUpdateThread(size + folders);

		// Copy process
		uint32_t value = 0;

		copy_entry = args->copy_list->head;

		for (i = 0; i < args->copy_list->length; i++) {
			snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name);
			snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name);

			if (args->copy_mode == COPY_MODE_EXTRACT) {
				addEndSlash(src_path);
				addEndSlash(dst_path);

				int res = extractArchivePath(src_path, dst_path, &value, size + folders, SetProgress);
				if (res < 0) {
					closeWaitDialog();
					errorDialog(res);
					goto EXIT;
				}
			} else {
				removeEndSlash(src_path);
				removeEndSlash(dst_path);

				int res = copyPath(src_path, dst_path, &value, size + folders, SetProgress);
				if (res < 0) {
					closeWaitDialog();
					errorDialog(res);
					goto EXIT;
				}
			}

			copy_entry = copy_entry->next;
		}

		// Set progress to 100%
		sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100);
		sceKernelDelayThread(COUNTUP_WAIT);

		// Close
		sceMsgDialogClose();

		dialog_step = DIALOG_STEP_COPIED;
	}

EXIT:
	if (thid >= 0)
		sceKernelWaitThreadEnd(thid, NULL, NULL);

	return sceKernelExitDeleteThread(0);
}
예제 #11
0
파일: stdio.c 프로젝트: CDragu/pspsdk
/*
**
**  [func] - rename.
**  [desc] -
**  [entr] - const char *name; the filename string pointer.
**           const char *newname; the new filename string pointer.
**  [exit] - int;
**  [prec] - name and newname are valid string pointers.
**  [post] - the name filen name is modified.
**
*/
int rename(const char *name, const char *newname)
{
	int ret = sceIoRename(name, newname);
	
	return (ret);
}