/* Copyright (C) 2008 Emmanuel Varoquaux
This file is part of XOS.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include
#include
#include
#include
#define TEST(cmd, exp_value) printf("%s: %s\n", #cmd, (cmd) == exp_value ? "OK" : "ECHEC");
int main()
{
int fd;
chdir("/floppy");
fd = open("A", O_WRONLY | O_CREAT);
write(fd, "Hello\n", 6);
close(fd);
mkdir("dirA", 0);
mkdir("dirA/dirB", 0);
fd = open("dirA/dirB/B", O_WRONLY | O_CREAT);
write(fd, "Youpi\n", 6);
close(fd);
fd = open("dirA/dirB/C", O_WRONLY | O_CREAT);
write(fd, "Blop\n", 5);
close(fd);
TEST(rename("A", "Hello"), 0);
TEST(rename("dirA", "nimp"), 0);
TEST(rename("nimp/dirB/C", "nimp/Blop"), 0);
TEST(rename("nimp/dirB", "exclamations"), 0);
TEST(rename("exclamations/B", "Youpi"), 0);
TEST(rename("Youpi", "exclamations/Youpi"), 0);
return 0;
}