19
3
Everybody has heard of the phrase "be there or be square". So I thought it was time for a challenge about it.
Input
You will take a full absolute directory address as text as input via STDIN or equivalent.
Output
If the directory address exists and is valid, your program will move itself to that folder on your computer. If not, it will output via STDOUT or equivalent the following square:
+-+
| |
+-+
Requirements
- Standard loopholes are disallowed.
- You may output a single trailing newline if unavoidable.
- Your program must produce no output if it has been moved.
- Your program must be able to run again wherever it has been moved to.
Assumptions
- You may assume that the input is never empty.
- You may assume the directory never has a filename appended to the end.
- You may assume that the input directory is never the current one.
- You may assume you have permissions to write and execute everywhere.
This is code-golf, so shortest answer in bytes wins.
Can we hardcode the filename? – BookOwl – 2017-01-22T20:27:40.357
Yes @bookowl you may – FinW – 2017-01-22T20:29:04.667
Does the path include the filename (
c:\users\Joe\program.txt
) or not (c:\users\Joe\
)? In the latter case, must the name of the created file be the same as the source? – Luis Mendo – 2017-01-22T21:33:18.007@LuisMendo you will never get a file as input only a directory – FinW – 2017-01-23T17:36:47.920
@FinW Sadly, you still haven't answered my question: must the name of the created file be the same as the original file? – Luis Mendo – 2017-01-23T17:37:09.167
@luismendo there isn't a created file – FinW – 2017-01-23T17:40:18.907
@LuisMendo You're moving, not copying, so I'd assume so. – mbomb007 – 2017-01-23T19:01:10.317
@FinW Not letting the filename be hardcoded makes it a bit more challenging i guess! – Abel Tom – 2017-01-25T14:21:47.010